Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

how to clone a object in javascript angular

const food = { beef: 'b', bacon: 'a' }

// "Spread"
{ ...food }

// "Object.assign"
Object.assign({}, food)

// "JSON"
JSON.parse(JSON.stringify(food))
Source by www.samanthaming.com #
 
PREVIOUS NEXT
Tagged: #clone #object #javascript #angular
ADD COMMENT
Topic
Name
1+2 =