Creating your own object part 3

JavaScript Tutorial
Objects
Creating Your Own Objects
66
3/3
               

Creating Objects



Consider the following example.
function person (name, age) {
this.name = name;
this.age = age;
}
var John = new person("John", 25);
var James = new person("James", 21);
Try It Yourself

Access the object's properties by using the dot syntax, as you did before.
Understanding the creation of objects is essential.

Comments

Popular posts from this blog

String Operators

Introducing object part 3

The math object part 2