const tempObj = { prop1 : "value1", prop2 : "value2" } //-----Concatinating / Adding New Key Values to Object--------// Object.assign(tempObj, { "prop123" : "value123", "prop456" : "value456" }, { "prop888" : "value888", "prop090" : "value090" } ) //--------Cloning an Object---------------// const clonedObject = Object.assign({}, tempObj) clonedObject.prop1 = "newProperty" //it does not affect the original object console.log(tempObj); //console.log(clonedObject, tempObj); //Find more in https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign //-----------------------------------------------------------//
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter