Underscore.js _.isWeakMap() Function Last Updated : 25 Nov, 2021 Comments Improve Suggest changes Like Article Like Report Underscore.js is a library in javascript that makes operations on arrays, string, objects much easier and handy. _.isWeakMap() function is used to check whether the given object is javascript weakmap or not. When linking the underscore.js CDN The "_" is attached to the browser as global variable. Syntax: _.isWeakMap(object); Parameters : object: It is any javascript object such as array, string, maps, set etc. Returns: It returns the boolean value. If the object is a weak map of javascript it returns true otherwise false is returned by the function. Few Examples are given below for a better understanding of the function. Example 1: When an array is given the output is false. javascript <!DOCTYPE html> <html lang="en"> <head> <meta charMap="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Document</title> <script src= "https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.9.1/underscore-min.js" > </script> </head> <body> <script> //creating a array of size 2 using constructor var obj= new Array(2); //filling value 10in the array obj.fill(5) //using the underscore.js function _.weakMap() var isWeakMap= _.isWeakMap(obj); console.log(isWeakMap) //If the given object is weakMap it prints the object is weak Map. if(isWeakMap) console.log(`The ${obj} is the WeakMap of Javascript.`) else console.log(`The ${obj} is not the WeakMap of Javascript.`) </script> </body> </html> Output: Example 2: When a weak set is given it returns true. javascript <!DOCTYPE html> <html lang="en"> <head> <meta charMap="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Document</title> <script src= "https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.9.1/underscore-min.js" > </script> </head> <body> <script> //creating a array of size 2 using constructor var obj= new WeakMap(); //using the underscore.js function _.weakMap() var isWeakMap= _.isWeakMap(obj); console.log(isWeakMap) //If the given object is weakMap it prints the object is weak Map. if(isWeakMap) console.log(`The ${obj} is the WeakMap of Javascript.`) else console.log(`The ${obj} is not the WeakMap of Javascript.`) </script> </body> </html> Output: Comment More infoAdvertise with us Next Article Underscore.js _.isWeakMap() Function T tarun007 Follow Improve Article Tags : JavaScript Web Technologies JavaScript - Underscore.js Similar Reads Underscore.js _.isMap() Function Underscore.js is a library in javascript that makes operations on arrays, string, objects much easier and handy. _.isMap() function is used to check whether the given object is javascript Map or not. Note: It is very necessary to link the underscore CDN before going and using underscore functions in 2 min read Underscore.js _.isWeakSet() Function Underscore.js is a JavaScript library that makes operations on arrays, string, objects much easier and handy. he _.isWeakSet() function is used to check whether the given object is JavaScript weakset or not. When linking the underscore.js CDN, the "_" is attached to the browser as global variable. S 2 min read Underscore.js _.isEmpty() Function Underscore.js _.isEmpty() function is used to check whether a list, array, string, object, etc is empty or not. It first finds out the length of the passed argument and then decides. If the length is zero, then the output is true otherwise false. Syntax:Â _.isEmpty(object);Parameters:It takes only on 3 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 _.isArray() Function The Underscore.js is a JavaScript library that provides a lot of useful functions like the map, filter, invoke, etc even without using any built-in objects. The _.isArray() function is used to find whether the passed argument is an array or not. An array is a set of variables, constants, and special 3 min read Like