Google News
logo
Lodash - Interview Questions
Lodash iterate object properties
The _.forIn() function can be used to iterate over object properties.
Example :
<!DOCTYPE html>
<html>
<head>
    <title>Lodash Tutorial</title>
    <script src="https://cdn.jsdelivr.net/npm/lodash@4.17.11/lodash.min.js"></script>

    <script type="text/javascript">
        // using Object Literals
        var user = {
            firstName: 'Free Time',
            lastName: 'Learning',
            emailId: 'info@freetimelearning.com',
            age: 31
        }

        _.forIn(user, (value, key) => {
            console.log(`${key}: ${value}`);
        })
    </script>
</head>
<body></body>
</html>
Output :

Lodash iterate object properties
Advertisement