Good evening guys, how are you? I am trying to understand the concept behind parentheses ('Tesla', 'Black', 20000); that involve the parameters at the end of the function. If I remove it the Car variable becomes a function otherwise it is an object. Is this parenthesis a self-invoking function?
let Car = function (model, color, price) { this.model = model; this.color = color; this.price = price; this.changeColor = function(){ this.color = 'Blue'; } this.getCar = function() { this.changeColor(); return console.log(`Model: ${this.model} Color: ${this.color} Price: ${this.price}` ) ; } return this; }('Tesla', 'Preto', 20000);
Car
model : 'Tesla' color : 'Preto' price : 20,000
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)