They are not the same, the second is a constructor for the Object:
var foo = {
a: 1,
b: 2
}
console.log("First: ",
typeof foo, // object
JSON.stringify(foo), // {a:1,b:2}
foo.constructor) // function Object() { [native code] }
var foo = function() {
this.a = 1;
this.b = 2;
}
console.log("Second: ",
typeof foo, // function
JSON.stringify(foo), // undefined, foo is not an Object, it's a function!
foo.constructor) // function Object() { [native code] }
var foo = new foo()
console.log("Thrid: ",
typeof foo, // object
JSON.stringify(foo), // {a:1,b:2}
foo.constructor) // function() { this.a = 1; this.b = 2;}
So even after creating both object you will have a diffrence in their .constructor
attribute. As the first Object was created by the Native constructor vor Object in JavaScript, and the second was created by your custom constructor.
But thats the only diffrence