Please anyone explain what are objects in JS? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 3

Please anyone explain what are objects in JS?

Objects

19th Mar 2020, 10:21 AM
I'mperfect Fems👧
I'mperfect Fems👧 - avatar
7 Answers
+ 3
Fems , I'll say have patience. Give one more try to lesson. If you fail to understand a "specific concept" you can ask me anytime. If you be specific in asking what you don't really understand ,I'll explain it in more details. But as Object itself is a very large topic It's not possible to cover just in few (1024) chars.
19th Mar 2020, 11:09 AM
🇮🇳Omkar🕉
🇮🇳Omkar🕉 - avatar
+ 4
I think Objects are used to store data values. Then what is the difference between variables and objects? I'm confused
19th Mar 2020, 10:46 AM
I'mperfect Fems👧
I'mperfect Fems👧 - avatar
+ 4
Thanks Omkar
19th Mar 2020, 11:22 AM
I'mperfect Fems👧
I'mperfect Fems👧 - avatar
+ 3
Fems , An object is collection of both data members and methods. Data members are like individual property of an object. Methods are the function that are bound to object and manipulate its own data. An example may make this clear. Ok, the good ol' OOP example , Car.. +data members : color maxSpeed brand millage etc. +methods : run() accelerate() stop() stear() reverse() etc. There are many ways to create objects in JS. You can use the one that better suits your need. +What advantage will an object offer? Imagine you are making a car game in which there will be several cars : 1.Every object is unique - every car being unique, if you stop one car it'll not affect state of another car. If one runs out of fuel this will not have effect on another. 2.Less variables - If you want to do things w/o objects there will be many variables. for example car1Color, car2Color and at one point I this code will become extremely unmanageable. Well many advantages are there. Char limit reached 😅
19th Mar 2020, 11:05 AM
🇮🇳Omkar🕉
🇮🇳Omkar🕉 - avatar
+ 3
narayanaprasad Thank you
21st Mar 2020, 7:04 AM
I'mperfect Fems👧
I'mperfect Fems👧 - avatar
+ 2
Have you read about objects in course.? May I know what have you understand about it so far? Objects in javascript or any other language are just like real world entities. They have their own state (properties) and behavior (methods)
19th Mar 2020, 10:33 AM
🇮🇳Omkar🕉
🇮🇳Omkar🕉 - avatar
21st Mar 2020, 6:22 AM
narayanaprasad
narayanaprasad - avatar