-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
34 lines (24 loc) · 697 Bytes
/
Copy pathscript.js
File metadata and controls
34 lines (24 loc) · 697 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
// Example By using an Object constructor:-
function Person(first, last, age, eye)
{
this.firstName = first;
this.lastName = last;
this.age = age;
this.eyeColor = eye;
}
// Create a Person object
const myFather = new Person("John", "Doe", 50, "blue");
console.log(myFather.firstName,myFather.lastName,myFather.age,myFather.eyeColor)
//Example By creating instance of Object:-
var emp=new Object();
emp.id=101;
emp.name="Ravi Malik";
emp.salary=50000;
console.log(emp.id+" "+emp.name+" "+emp.salary);
//Example avaScript Object by object literal:-
emp={
id:102,
name:"Shyam Kumar",
salary:40000
}
console.log(emp.id+" "+emp.name+" "+emp.salary);