Understanding the Difference Between Object.create and New Operator
Too Long; Didn't Read
Object.create and new operator are different methods used in Javascript. Object.prototype is created in an object and is assigned to its own property. Object.create creates an object having its own properties defined as a second property. New operator creates an empty object and runs Animal constructor in newly created object context. Animal.prototype.getName = function ( ) { this.name = null ; } Animal.prototype.prototype.getName;. Animal. constructor will run so whatever script is written in Animal constructor will. run. Object object is stored in Animal.call(obj)
Share Your Thoughts