This has been answered before, but I wanted to confirm my understanding. In this code:
var somePrototype = {
speak: function() {
console.log("I was made with a prototype");
}
}
function someConstructor() {
this.speak = function() {
console.log("I was made with a constructor");
}
}
var obj1 = Object.create(somePrototype);
var obj2 = new someConstructor();
obj1.speak();
obj2.speak();
They are both fundamentally doing the same thing, correct? The only difference is that the function someConstructor() is hoisted, meaning I can call new instances of it before it is defined, if needed, while the var somePrototype can only be called after it's been defined. Other than that, there's no difference?
Object.create().