+ 1
what is the difference between function and method ?
4 ответов
+ 3
JavaScript does not have classes. Method belongs to objects.
document.write()
The write() method belongs to the document object.
+ 1
A method is a function belonging to a class.
0
Think of a method like a function that is attached to a specific method.. A function can be called from a global space. Where methods must be called from their object.
function addmultdiv(a,c,b){
if(b > 0){
return ((1+a)*c)/b;
} else {
return 0;
}
}
You can call addmultdiv from anywhere
Whereas a method is a function attached to and only accessable by its object.
0
A method commonly refers to a function that's a property of a class (either a static or instance method), while a function is the more general term for a procedure that takes arguments and returns a value after being called. Methods are functions.
see this:https://www.google.co.in/url?sa=t&rct=j&q=&esrc=s&source=web&cd=2&cad=rja&uact=8&ved=0ahUKEwiHiv2xjenOAhWHQ48KHUC9BS4QFggdMAE&url=https%3A%2F%2Fwww.quora.com%2FWhats-the-difference-between-a-method-and-function-in-JUMP_LINK__&&__Python__&&__JUMP_LINK&usg=AFQjCNFuIrLSWx_Oq37HkEmtcsR9SS9uCQ&sig2=zSAHbnB5lM_ROxGkf-wosg