Is there a difference in the type of the object between the two instances of joe
below?
var Person = function(name)
{
this.name = name;
};
var joe = new Person("Joe Bloggs");
console.log(typeof joe);
==========================================
var Person = function(name)
{
this.name = name;
return this;
};
var joe = new Person("Joe Bloggs");
console.log(typeof joe);
I'd like to refine my question. I am not really asking how to determine the type of an object in JavaScript, although that too is a question of mine but over here, that's not what I am asking.
Over here, what I am asking is, is:
var Foo = function() { }
var foo = new Foo();
the same as (or how is it different from)
var Foo = function() { return this; }
var foo = new Foo();