Lodash.js – isEmpty() function

A simple Lodash.js example of the isEmpty() function, we will check if the provided variable is empty (has a greater length than 0, is an Array, Object, Arguments, enumerable, jquery obj, etc).
<!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');

    var firstValue = 1;

  firstDiv.innerHTML = "Having the variable " + firstValue + " we will check if it is empty (has a greater length than 0, is an Array, Object, Arguments, enumerable, jquery obj, etc)...";

    var result = _.isEmpty(firstValue);

  secondDiv.innerHTML = "...and we get: " + result;

</script>
</body>

</html>

Responses

0 Replies