I want to know why there is difference between the outputs of the following classes.
I have tried following code to get the class values in console. For one particular case(the last console) I am wondering how this is returning this value.
let rectangle = class{
constructor(name,num){
this.name =name;
this.num = num;
}
}
let rect = new rectangle();
console.log("bantai",rect);
//output: rectangle { name: undefined, num: undefined }
let rectangle3 = class rectangle2{
constructor(model, version){
this.model = model;
this.version = version;
}
}
var abh = new rectangle3();
console.log(abh);
//output:rectangle2 { model: undefined, version: undefined }
console.log(rectangle3);
//output:[Function: rectangle2]
I am wondering about the last console console.log(rectangle3) value why it is returning this value as array with one element ie [Function: rectangle2]