Skip to content
Permalink
717e9e670e
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
31 lines (29 sloc) 1.02 KB
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>MDN Object Tutorial</title>
</head>
<body>
<script>
function Person(first, last, age, gender, interests) { //constructor function
this.name = {
first: first,
last: last
};
this.age = age;
this.gender = gender;
this.interests = interests;
this.bio = function() { //method
alert(this.name.first + ' ' + this.name.last + ' is ' + this.age + ' years old. She likes ' + this.interests[0] + ' and ' + this.interests[1] + '.');
};
this.greeting = function() { //method
alert('Hi! I\'m ' + this.name.first + '.');
};
}
let person1 = new Person("Mahnoor", "Afteb", 20, "female", ["music", "movies"]) //object
</script>
</body>
</html>