javascript - How to create new json object from exiting one? -


this question has answer here:

i want create new json object exiting one, because if create

var person1= { first name: 'john',   last name: 'smith',   age: 54,   dateofbirth: '31-08-68',  } var person2=person1; delete person2.age 

this delete age person1, don't want delete age person1, person2. because need initialize other person also. how create new json object exiting object .

you must clone object. quick way is

var person2=json.parse(json.stringify(person1)); 

Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -