I have a typescript class
export class Restaurant {
constructor ( private id: string, private name: string ) {
}
public getId() : string {
return th
Using standard ES6 features
const clone = Object.assign({}, myObject)
Warning: this performs a shallow clone.
This excellent page from MDN contains tons of details on cloning, including a polyfill for ES5
A "quick" way of deep cloning is to use JSON
utilities
const clone = JSON.parse(JSON.stringify(myObject))
A "proper" way of cloning is to implement a clone method or a copy constructor...
I know, I know, not enough JQuery