Three different ways to loop through JavaScript objects

Learn how to loop through objects in Javascript. var object = { name : “Javascript Jeep”, status : “😎”, icons : “πŸš—” } Using for..in With ES6, we can use Object.entries to loop through each entry of the object. The Object.entries method returns an array of [key, value]. We can also use Object.keys which will …

Get keys of the object in javascript

Object.keys() method can be used to get the keys of the object. We get the keys in same order as we get in the normal for..in loop It returns an array filled with the keys of the object. // array var num = [1 , 2, 3];console.log(Object.keys(num)); // [‘0’, ‘1’, ‘2’] // objectvar obj = …

The correct way to delete an object and its referring objects in javascript .

Let’s create an object let obj1 = { name : “Stark”, age : 23} Create another variable with the value referring to the obj1 let obj2 = obj1; Now we know that whatever operation we do on obj1 alters the value in obj2 and vice versa. obj1.job = “superhero”; obj1 // {name: “Stark”, age: 23, …

Design a site like this with WordPress.com
Get started