What do you want to save?
Add Code snippet
New code examples
-
Javascript 2022-02-02 17:41:22
clone an object javascript
var student = {name: "Rahul", age: "16", hobby: "football"}; //using ES6 var studentCopy1 = Object.assign({}, student); //using spread syntax var studentCopy2 = {...student}; //Fast cloning with data loss var studentCopy3 =... Add solution -
Javascript 2022-01-30 21:15:20
function calls
const obj = { foo: 1, get bar() { return 2; } }; let copy = Object.assign({}, obj); console.log(copy); // { foo: 1, bar: 2 } // The value of copy.bar is obj.bar's getter's return value. // This is an assign function that copies full descript... Add solution -
Javascript 2021-11-20 15:26:09
array of objects to object
const names = ['Alex', 'Bob', 'Johny', 'Atta']; // convert array to th object const obj = Object.assign({}, names); // print object console.log(obj); // {0: "Alex", 1: "Bob", 2: "Johny", 3: "Atta"} Add solution -
Javascript 2021-11-19 13:02:18
best way to clone an object in javascript
var student = {name: "Rahul", age: "16", hobby: "football"}; //using ES6 var studentCopy1 = Object.assign({}, student); //using spread syntax var studentCopy2 = {...student}; //Fast cloning with data loss var studentCopy3 =... Add solution -
Javascript 2021-11-19 06:23:18
convert array to object in javascript
const names = ['Alex', 'Bob', 'Johny', 'Atta']; // convert array to th object const obj = Object.assign({}, names); // print object console.log(obj); // {0: "Alex", 1: "Bob", 2: "Johny", 3: "Atta"} Add solution
Best helpers
+5
+5
+5
+5
+5
+5
+5
+5
+5
+5
+5