How do you create a new object in JavaScript?

Recommended Answers

All 2 Replies

profile=new Object();
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 developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.