But, we don’t want to be creating copies of functions instead we want all the objects to share the same function code. ![]() ![]() If we want to create 200 Company objects there will be 200 copies of getName().The above code is working fine but the problem with getting the output from the approach.This.name=name //this keyword used for instance of the same objectĭocument.write(company1.getName()+"") //gives you new line ![]() Var v=new Object(values,….) Why do we move into the concept of Prototype?īelow examples illustrate why we are discussing the prototype concept in JavaScript Example #1
0 Comments
Leave a Reply. |