Understanding the Difference Between Object.create and New Operator

Written by vaibhavsilar | Published 2021/08/23
Tech Story Tags: javascript | programming | javascript-fundamentals | coding | tech-beginners-guide | javascript-object-entries | understanding-javascript | javascript-tutorial

TLDR 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)via the TL;DR App

no story

Written by vaibhavsilar | writing simple code is the most complex task
Published by HackerNoon on 2021/08/23