I have written following code
1.
function Car() {
this.make = "BMW"
}
var x = new Car().make
alert(x)
Result: shown alert BMW
2.
function Car() {
this.make = "BMW"
}
var x = Car().make //removed new keyword
alert(x)
Result: did not show alert BMW. Error in console "Cannot read property 'make' of undefined"
3.
function Car() {
this.make = "BMW"
return this //added return
}
var x = Car().make //removed new keyword
alert(x)
Result: shown alert BMW
Can anybody explain, what exactly happening, when I return 'this' ...?