1.

Anonymous functions vs JavaScript closures

Answer»

The object properties are variables used internally in the object's methods. These variables can also be globally visible throughout the page. The properties are the values associated with a JavaScript object.

Let US SEE how to create and ACCESS object properties:

<!DOCTYPE html> <html> <body> <H2>Department</h2> <p id="myid"></p> <script> var department = {   id: 5,   name : "Finance",   Location     : "NORTH" }; document.getElementById("myid").innerHTML = department.id + " is " + department.name + " department's id."; </script> </body> </html>

The following is the output: 

Above we access the object properties as:

objectName.property

As shown above, we used to access object properties. Here, “Department” is our object whereas “name” is our property: 

department.name


Discussion

No Comment Found