Underscore.js _.isZero() Method
Last Updated :
31 Jul, 2020
The _.isZero() Method checks whether the given value is a Zero value or not, correspondingly returning a boolean value.
Syntax:
_.isZero(value);
Parameters: This method accepts a single parameter as mentioned above and described below:
- value: Given value to be checked for Zero value.
Return Value: This method returns a Boolean value(Returns true if the given value is Zero, else false).
Note: This will not work in normal JavaScript because it requires the underscore.js contrib library to be installed.
underscore.js contrib library can be installed using npm install underscore-contrib –save.
Example 1:
Javascript
var _ = require( 'underscore-contrib' );
console.log( "The Value is Zero : " +_.isZero(0));
|
Output:
The Value is Zero : true
Example 2:
Javascript
var _ = require( 'underscore-contrib' );
console.log( "The Value is Zero : " +_.isZero(10));
|
Output:
The Value is Zero : false
Example 3: For string containing zero this returns false
Javascript
var _ = require( 'underscore-contrib' );
console.log( "The Value is Zero : " +_.isZero( "0" ));
|
Output:
The Value is Zero : false
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...