You can create a class Car, try this:
class Car {
constructor(name, price){
this.name = name,
this.price = price
}
}
function createNewObject() {
let car1 = new Car('Tesla', 20);
console.log(car1);
}
<button onclick="createNewObject()">Generate</button>
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…