Constructor functions return statement

26 views Asked by At

Can you explain me the differences between these two provided examples or provide me articles to read?

function x (){
    this.name="Diana"
    return [1,2,3]
}
let newOne = new x() // the return value is an array instead of the object

function ValString (){
    this.name="Diana"
    return 12
}
let newOneWithTheString = new ValString () // the return value is an object instead of the 12

0

There are 0 answers