Underscore.js _.invert() Function

The _.invert() function is used to return the copy of an object where the object key is converted into value and object value is converted into the key. It means the [key, value] of the object is reverse.
Syntax:
_.invert( object )
Parameters: This function accepts single parameter as mentioned above and described below:
- object: It contains the object element that holds the elements of key and value pair.
Return Value: It returns the [key, value] of an object in reverse [value, key] order.
Example 1:
| <!DOCTYPE html> <html>  Â<head>     <scripttype="text/javascript"            src=     </script> </head>  Â<body>     <scripttype="text/javascript">  Â        var obj = {             Company: "zambiatek",             Address: "Noida",             Contact: "+91 9876543210",             Email: "abc@gfg.com"         }         console.log(_.invert(obj));     </script> </body>  Â</html>  | 
Output:
Example 2:
| <!DOCTYPE html> <html>  Â<head>     <scripttype="text/javascript"            src=     </script> </head>  Â<body>     <scripttype="text/javascript">  Â        var inv = _.invert({             num1: 10,             num2: 20,             num3: 30,             num4: 40         });  Â        console.log(inv);     </script> </body>  Â</html>  | 
Output:
Whether you’re preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, zambiatek Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we’ve already empowered, and we’re here to do the same for you. Don’t miss out – check it out now!
 
				 
					



