How do you create a new object in JavaScript?

Recommended Answers

profile=new Object();
profile.FName="Vijayakumar";
profile.Lname="S";
document.write(profile.FName+" "+profile.Lname);

Created Object & new instances of an Object & added 2 properties to it... :)

Jump to Post

All 2 Replies

profile=new Object();
profile.FName="Vijayakumar";
profile.Lname="S";
document.write(profile.FName+" "+profile.Lname);

Created Object & new instances of an Object & added 2 properties to it... :)

var me = {fname : "Vimal", lname : "Anand", age : 23, workplace:"The Hackett Group"}
//Created an object "me"

The object's children can be used as "Object.firstChild" eg: "console.log(me.fname)"

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.20 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.