Pls can any one tell me the difference between "objects" , "methods" and functions; | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Pls can any one tell me the difference between "objects" , "methods" and functions;

Although I've gotten a good grasp of function, the former two are still mystery. I might be including 'em in codes but truthfully speaking,"I DON'T KNOW THESE GUYS". Pls an explanation with examples of/on each(method && object) would be highly appreciated. Thank you!!

21st Jun 2018, 3:35 PM
Anansi
Anansi - avatar
2 Answers
+ 2
Object is instance of a class. While method is function in a class.
21st Jun 2018, 3:39 PM
Lstiti
+ 1
Function : Function are used to reduce code in your program. For example : Suppose your program is based on adding numbers. Instead of doing addition every time , you can define function once and call it as many times as you want. Object : Object is used to store data in name (key) value pair. It can be useful to store real world things. For example : If you want to store details of book such as page no. , author , book name , etc. You can with usage of objects. var bookDetails ={ author : abc , bookTitle : objects , pageNumber : 13 //and so on..... } Method : Method is just function inside objects. Hope this helps you.
21st Jun 2018, 5:01 PM
Meet Mehta
Meet Mehta - avatar