You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Object.keys(obj)// array of keysObject.values(obj)// array of valuesObject.entries(obj)// array of [key, value] pairsObject.assign({},src)// shallow copy / mergeObject.freeze(obj)// prevent modificationsObject.isFrozen(obj)// check if frozenObject.hasOwn(obj,"key")// own property check (modern)obj.hasOwnProperty("key")// own property check (classic)
Destructuring
const{ name, age }=person;// basic destructuringconst{name: n,age: a}=person;// rename while destructuringconst{ name ="Unknown"}={};// default value// Nested destructuringconst{address: { city }}=user;// Function parameter destructuringfunctiondisplay({ name, age =0}){console.log(name,age);}display(person);// Array destructuringconst[first,second, ...rest]=[1,2,3,4,5];// Swap variablesletx=1,y=2;[x,y]=[y,x];