×

Html & Html5

it training classes Logo

The World's best Software Development Study Portal

JavaScript Objects



A Javascript object is a collection of named values. The Named Values, in Javascript objects, are called properties.

Objects are variables containing Variables Javascript variables can Contain single values. Objects are variables too. But objects can Contain many values.

1.By object literal

2.By creating instance of Object directly

3.By using an object constructor

<script>

emp={age:30,name:"Parveen",salary:90000}

document.write(emp.age+" "+emp.name+" "+emp.salary);

</script>

---------------------------------------------------------------------------------

Example-2



<script>

var deepak=new Object();

deepak.id=501;

deepak.name="Deepak kumar";

deepak.salary=85000;

document.write(deepak.id+" "+deepak.name+" "+deepak.salary);

</script>

-----------------------------------------------------------------------------------

Example-3



<script>

function deep(id,name,salary){

this.id=id;

this.name=name;

this.salary=salary;

}

e=new deep(203,"Parveen Barak",70000);

document.write(e.id+" "+e.name+" "+e.salary);

</script>








JS training insitute | Best IT Training classes in Gurgaon | Web Designing Training Institute