Error in implementing Inheritance in javascript -


var old = {name:'abc',id:'3'}; new = object.create(old); alert(new.name); 

i trying run simple example not working. can wrong?

edit: made mistake taking reserved keyword variable name, please dont kill me that. happens.

the following makes sense :

var parent = {name:'abc',id:'3'}; child= object.create(parent ); child(new.name); 

for other user landing here searching inheritance in javascript in javascript inheritance achieved linking object other shown above. when use variable, javascript engine search variable in current object , if not find it, linked object , value there.

thanks. cheers!!

new keyword.

you need update from

new = object.create(old); alert(new.name); 

to

var x = object.create(old); alert(x.name); 

Comments

Popular posts from this blog

user interface - how to replace an ongoing process of image capture from another process call over the same ImageLabel in python's GUI TKinter -

javascript - Using jquery append to add option values into a select element not working -

javascript - Restarting Supervisor and effect on FlaskSocketIO -