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
Post your comments / questions
Recent Article
- How to restrict access to the page Access only for logged user in Django
- Migration admin.0001_initial is applied before its dependency admin.0001_initial on database default
- Add or change a related_name argument to the definition for 'auth.User.groups' or 'DriverUser.groups'. -Django ERROR
- Addition of two numbers in django python
- The request was aborted: Could not create SSL/TLS secure channel -Error in Asp.net
- FieldError: Cannot resolve keyword 'id' into field in Django project
- How to hide the ID field from the Django admin?
- It is impossible to add a non nullable field without specifying a default. Django error
Related Article