class Shape {
constructor(
public lineCount: number,
public name: string) {}
public toString(): string {
return `${this.name}, ` +
`lineCount is ${this.lineCount}`
}
}
let square = new Shape(4, "Square")
// Copy without methods
let clone1 = { ...square }
// Clone sees changes to original
let clone2 = Object.create(square)
square.lineCount = 5
square.name = "Red sqare"
console.log(square.toString())
console.log(clone1.toString())
console.log("clone1.lineCount is",
clone1.lineCount)
console.log(clone2.toString())