create account

What is Object In JavaScript Programming Language ( For beginners ) by pakgamer

View this thread on: hive.blogpeakd.comecency.com
· @pakgamer ·
$5.77
What is Object In JavaScript Programming Language ( For beginners )
## Hello Everyone!

In the last post, we have discussed arrays in JavaScripts. In this post, we are going to understand the objects in the JavaScript programming language.


![image.png](https://images.hive.blog/DQmWMe7DqL6h8TqNN9PL6gQahfxnTyNKVz6RJAfauA5FKKG/image.png)
[Image source](https://www.tutorialrepublic.com/lib/images/javascript-illustration.png)
## What is objects
 * The objects in Javascript is a unique entity which contains property and methods. You can say that property is a variable and method is a function. Let's write some code to understand the objects in Javascript.

* Suppose I want to store some information about a user of hive platform. let's say my own account data. Here the mechanism of Object-Oriented programming is used which is objects. The object-oriented programming contains the following features 
1.  Object
2. Classes
3. Encapsulation
4. Inheritance

We will discuss the rest in other post but for now, we need to focus on Objects.
Ok. to solve the above problem we can write a code something like that.


![image.png](https://images.hive.blog/DQmV7pTZwJhgpQvyghnkokhimhanPCnVEyaqV2xbG7Q9tpC/image.png)





* This is an object with name users that contain some properties. Actually, this object contains some information about my own accounts like Hive Power, HBD, Hive Coin, and a few more things. 
![image.png](https://images.hive.blog/DQmaxcoyAGmtVr6kc2nvzB7KTxBWExEN3EzDVgv3AdQHdxc/image.png)
Here name is the property of user object. Now if I want to access the one property let's say I want to see the Hive Power so I can access the property just by typing the ``objectName . property``

![image.png](https://images.hive.blog/DQmVVujKhg2LCaSoVfFHABesiAZeFqxPUZHpHHhvDdRj7Cz/image.png)
* As in the above snap the IDE is showing the properties of that particular class. Here I want to hivePower property so I will select the hivePower and run the code.


![image.png](https://images.hive.blog/DQmQtRsHsu5RNJTo8w9v6WnAAsECMShahpKKocxbJPrf9xF/image.png)

 

* And here you can see the hivePower is printed on the console. We can either assign the property to a variable and then print the variable. Just like this

![image.png](https://images.hive.blog/DQmSMEvgxj9ctcnt2m9hcdYR11ranozLmHnN5L416tPSDoc/image.png)
* We can print the whole object as well.

![image.png](https://images.hive.blog/DQmR8pqdwmdUXQzsBtEkhC4QP9oBRdRSHbB1N1pQyHMnKd9/image.png)

* We can also access the property this way. ``objectName[propertyName]``

![image.png](https://images.hive.blog/DQmVaeugUXnP7eyR84HTHNirzVa9LV6gMkoXPC8gwG1w4Eu/image.png)

* Now to create a Method. The syntax is `` functionName: function(){//code}``


![image.png](https://images.hive.blog/DQmSFkesspVQ1csG4yePM1AGckehWYVGFiEwFnkSXqfgpYN/image.png)
* Here we have a method with the name hello that will print ``Hello hive users``. 


* If we need to revalue a property we can do it something like this.

![image.png](https://images.hive.blog/DQmenPJ3CxRMQebm92PDcfGqEevJiPpqV49evRkoMBgr8sj/image.png)

* We can create a new property outside of the object.

![image.png](https://images.hive.blog/DQmYvg8F5TQnEY19rzUbYYa2gmosF7f7MHPvgK3XfwBNpc5/image.png)
 
**I think this much is enough for today. We will discuss objects in details once cover the other basics for now keep practice, Take care and see you with a new post.**
👍  , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , and 139 others
properties (23)
authorpakgamer
permlinkwhat-is-object-in-javascript-programming-language-for-beginners
categoryhive-148441
json_metadata{"tags":["programming","learning","posh","coding"],"image":["https://images.hive.blog/DQmWMe7DqL6h8TqNN9PL6gQahfxnTyNKVz6RJAfauA5FKKG/image.png","https://images.hive.blog/DQmV7pTZwJhgpQvyghnkokhimhanPCnVEyaqV2xbG7Q9tpC/image.png","https://images.hive.blog/DQmaxcoyAGmtVr6kc2nvzB7KTxBWExEN3EzDVgv3AdQHdxc/image.png","https://images.hive.blog/DQmVVujKhg2LCaSoVfFHABesiAZeFqxPUZHpHHhvDdRj7Cz/image.png","https://images.hive.blog/DQmQtRsHsu5RNJTo8w9v6WnAAsECMShahpKKocxbJPrf9xF/image.png","https://images.hive.blog/DQmSMEvgxj9ctcnt2m9hcdYR11ranozLmHnN5L416tPSDoc/image.png","https://images.hive.blog/DQmR8pqdwmdUXQzsBtEkhC4QP9oBRdRSHbB1N1pQyHMnKd9/image.png","https://images.hive.blog/DQmVaeugUXnP7eyR84HTHNirzVa9LV6gMkoXPC8gwG1w4Eu/image.png","https://images.hive.blog/DQmSFkesspVQ1csG4yePM1AGckehWYVGFiEwFnkSXqfgpYN/image.png","https://images.hive.blog/DQmenPJ3CxRMQebm92PDcfGqEevJiPpqV49evRkoMBgr8sj/image.png","https://images.hive.blog/DQmYvg8F5TQnEY19rzUbYYa2gmosF7f7MHPvgK3XfwBNpc5/image.png"],"links":["https://www.tutorialrepublic.com/lib/images/javascript-illustration.png"],"app":"hiveblog/0.1","format":"markdown"}
created2020-04-15 20:04:42
last_update2020-04-15 20:04:42
depth0
children0
last_payout2020-04-22 20:04:42
cashout_time1969-12-31 23:59:59
total_payout_value2.923 HBD
curator_payout_value2.849 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length3,321
author_reputation19,304,605,112,640
root_title"What is Object In JavaScript Programming Language ( For beginners )"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id96,855,439
net_rshares18,251,451,474,301
author_curate_reward""
vote details (203)