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!!
2 Answers
+ 2
Object is instance of a class. While method is function in a class.
+ 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.