Lodash.js – values() function

A simple Lodash.js example of the values() function, which creates an array from the provided objects' enumerable variable values. It does not include inherited values.
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8"/>
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
    <meta name="description" content="Tizen example"/>
    <title>Tizen lodash.js example</title>
    <script src="js/lodash.min.js"></script>
</head>
<body>
<div id="first">
</div>
<br>
<div id="second">
</div>

<script>

    var firstDiv = document.getElementById('first');
    var secondDiv = document.getElementById('second');

    function Dog() {
      this.eyes = 'brown';
      this.tail = 'short';
      this.ears = 'long';
    }


  firstDiv.innerHTML = "Having instantiated the Dog object:<br><br>";

    var dog = new Dog();
    var result = _.values(dog);

    firstDiv.innerHTML += JSON.stringify(dog);

  secondDiv.innerHTML = "...we will create an arrays consisting of the provided objects' key values... and we get:<br><br>";

  secondDiv.innerHTML += JSON.stringify(result);

</script>
</body>

</html>

Responses

0 Replies