Underscore.js _.isUndefined() Function (original) (raw)
Last Updated : 01 Aug, 2023
_.isUndefined() function:
- It checks if the parameter passed to it is undefined or not.
- If the parameter passed is undefined the it return true otherwise it returns false.
- We can even pass window elements to it.
Syntax:
_.isUndefined(value)
Parameters:
It takes only one argument which is the value or the variable that needs to be checked.
Return value:
It returns true if the value or parameter passed is undefined or else it returns false.
Examples:
- Passing a variable to the _.isUndefined() function:
The _.isUndefined() function takes the parameter passed to it. So, here it will check the variable ‘a’ which is passed. Since the value of ‘a’ is defined earlier as 10, so, it is a defined variable. Hence, the output will be false.
Output: - Passing a number to the _.isUndefined() function:
If we pass a number to the _.isUndefined() function then it checks whether that number is undefined or not. Since, we know all numbers are defined already. Therefore, the answer will be false.
Output: - Passing “undefined” to _.isUndefined() function:
The _.isUndefined() function takes the element passed to it which is “undefined” here. Since the parameter passed is undefined, therefore the output will be true.
Output: - Passing missingVariable to the _.isUndefined() function:
Here we are passing ‘window.missingVariable’ as a parameter. But here we have not defined any variable. So the missingVariable has no value. And hence, it is undefined. The output is true.
Output:
NOTE: These commands will not work in Google console or in firefox as for these additional files need to be added which they didn’t have added.
So, add the given links to your HTML file and then run them.
The links are as follows:
Similar Reads
- Underscore.js _.isFinite() Function The _.isFinite() function is used to check whether the value of the parameter passed is finite or not. If the parameter has an infinite value the output is false otherwise, true. We can even perform any operation like addition, subtraction in this function. Syntax:_.isFinite(object) Parameters:It ta 3 min read
- Underscore.js _.isFunction() Function The _.isFunction() function is used to check whether the given object is function or not. It returns a Boolean value True if the given object is a function and returns False otherwise. Syntax: _.isFunction( object ) Parameters: This function accepts single parameter as mentioned above and described 1 min read
- Underscore.js _.isNaN() Function _.isNaN() function: It is used to find whether the value of the object passed is NaN or not.If the object's value is NaN then the output will be true otherwise, it will be false.We can even perform addition, subtraction etc operations in this function. Syntax: _.isNaN(object) Parameters:It takes onl 3 min read
- Underscore.js _.isDate() function Underscore.js is a javascript library that is capable enough to handle arrays, strings, objects, map, set very easily and efficiently. The _.isDate() function in underscore.js is used to tell if the given object is a date object or not. Syntax: _.isDate(object); Parameters: It takes only one paramet 1 min read
- Underscore.js _.isSet() Function Underscore.js is a library in javascript that makes operations on arrays, string, objects much easier and handy. _.isSet() function is used to check whether the given object is javascript set or not. When linking the underscore.js CDN The "_" is attached to the browser as global variable. Syntax: _. 2 min read
- Underscore.js _.isDataView() Function Underscore.js is a JavaScript library that provides a lot of useful functions that help in the programming in a big way like the map, filter, invoke, etc even without using any built-in objects. The _.isDataView() function is an inbuilt function in Underscore.js library of JavaScript which is used t 1 min read
- Underscore.js _.isNull() Function Underscore.js _.isNull() function It is used to find whether the value of the object is null. If an object has a null value then the output will be true otherwise false. We can even perform addition, subtraction, etc operations in this function. Syntax:Â _.isNull(object);Parameters:It takes only one 3 min read
- Underscore.js _.isString() Function The _.isString() function is used to check whether the given object element is string or not. Syntax: _.isString( object ) Parameters: This function accepts single parameter as mentioned above and described below: object: It contains the value of object that need to be check whether it is an string 1 min read
- Underscore.js _.isNumber() Function Underscore.js _.isNumber() function is used to check whether the given object parameter is a number or not. If the given object is a number then it returns True value otherwise, it returns False. Syntax:_.isNumber( object );Parameters:object: This parameter holds the object element that needs to be 1 min read
- Underscore.js _.isRegExp() Function _.isRegExp() function: It finds whether the object passed is a regular expression or not. If the object is a regular expression then it returns true otherwise false. We can even apply operations like addition etc on the variables in which the result of _.isRegExp() is stored. Syntax: _.isRegExp(obje 3 min read