Object in javascript
In this article,we are creating an object in javascript. In this article you will learn how to create object in javascript. Object start with curly bracket and ends with curly bracket,it works on (key-value) mechanism.(key-value) pair is a combination of string also,means we can assign a string to key and value also.Objects can be copy by reference not by value. In up comming litures we will learn about copy by value and copy by reference.
How to create object in javascript
Object is start with curly bracket and end with curly bracket. Below example explain complete structure of object. Objects are none primitive data type
1let myObject = {
2 id: 1,
3 name: "abc",
4 }
We have created object of two properties named 'id' and 'name'. On left side is properties of object and on the right side is values of those properties.
Update property of Object in javascript
We can easily change or modify the objects
1let ab = {
2 id: 1,
3 name: "abc"
4 };
5
6 ab.name = "xyz";
7 console.log(ab); // {id: 1, name: "xyz"}
In this example we have updated name property object. Before it was 'abc' and now it is 'xyz'
About
Moiz is a software engineer from Arid University with a passion for writing tech tutorials and doing coding. I am continously produce JavaScript and other web development technology tutorials in concepts through easy-to-understand explanations written in plain English.I have expertise in next js ,react js ,javascript,html,bootstrap and node js.
Follow him on TwitterHassan is a software engineer from kohat university of science and technology with a passion for writing tech tutorials and doing javascript practices on daily basis.I have expertise in next js ,react js ,javascript,html,bootstrap and node js. Problem Solving and making concpets is my strong point.
Follow him on TwitterTags
Click to see all tutorials tagged with: