JavaScript Objects

1/22/2020 2:01:22 AM

Object contain collection of property, function, this property represents the key and name. other programming language and JavaScript have same concept for object. But when declare JavaScript object its some change in syntax. We can define our won object and write property. Now we create an object and set the property value and also, we get the value from the object. We can use some predefine method on object. Now given bellow the example code and explain the code:

<!DOCTYPE html>
<script type="text/javascript">
  // JavaScript create object
var human= {};
  // JavaScript Assign object = 'Jesy';
human.color = 'white';
human.age = 24;
  // JavaScript print object proparty
 console.log("Name :"+human['name']);
 console.log("Color :"+human['color']);

In this part we create an object name as human then we write some property like name, color, age etc. now we print the property value.