c# .net Adsense ADO.NET Linq Viruses/security asp.net MVC JQuery Angular-js Node-js SEO Java C++ SQL API Networking vb.net .Net Css JavaScript Generics c#.Net entity framework HTML Website host Website Construction Guide HTTP tutorial W3C tutorial Web Services JSON Psychology Ionic framework Angular ReactJS Python Computer Android
JavaScript

How to create an object using object literal notation in JavaScript?

| | JavaScript

In this article we will discuss, how to create an object using object literal notation in JavaScript. When we change made to the objects, it affects entire object of the script.

Below example describes about that, creating a new object as student and assigned to a variable. Beginning we have assigned name property to thivan then create new variable for student object and assign name property to mydeen.

<script type="text/javascript">

    var student =

    {

        name: "thivan"

    }

    // Create a new variable andassign the student object

    var newStudent = student;

    // Change the name property of thestudent object using the new variable

   newStudent.name = "mydeen";

    // Retrieve the name property fromthe original student object

    // Notice that name is changed toMary

   document.write(student.name);

</script>

Output:

 Mydeen