What is Object in JavaScript With Example


In JavaScript, objects are data (variables), with properties and methods.
Almost "everything" in JavaScript are treated as objects. Dates, Arrays, Strings, Functions....
In JavaScript you can also create your own objects.


This example creates an object called "person", and adds Three properties to it:

<html>
<body>


<h1  id="per">  </h1>
<Button onclick="Info()" >  Click Here TO Get Information</button>
</body>
<script>

function Info()
{
var  person={firstname:"abdullah" ,LastName:"Masood" , RollNo:"026"};

document.getElementById("per").innerHTML="First Name is : "+person.firstname+"<br>"
 +"Last Name is : "+person.LastName +"<br>  RollNo is : "+ person.RollNo;
}
</script>

</html>