This was said earlier, 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 both basically do the same thing, right? The only difference is that the function someConstructor() raised, which means that I can call new instances before it is defined, if necessary, and var somePrototype can only be called after it is defined. Other than that, no difference?
source share