+ 9

I am confuse between function and method, how can differ between them?

5th Mar 2016, 1:56 PM
NANDRAJ PATIDAR
NANDRAJ PATIDAR - avatar
11 odpowiedzi
+ 21
A function is a statement that can be called when you type the word you used to define it as, A method is when you use any function as a value tied to a specific property inside of an object. All methods are also functions (just used in at least one object) but not all functions are methods (because you can create a function and never use it with an object)
23rd Mar 2016, 5:29 PM
emma
emma - avatar
+ 8
functions are independent. They can operate outside class like in C++ or C. Methods by definition will exist and operate only within classes.
9th Jun 2016, 6:49 PM
ರಾಜ್
ರಾಜ್ - avatar
+ 3
For the most part it's computer scientist trying to sound smart. If you confuse the two, no harm done. In Javascript: var bankaccount = { 'withdraw' : function(){ ... } }; We say `withdraw` is a function, but it is also a method of `bankaccount`. In other words, methods are functions belonging to objects.
10th Oct 2016, 5:02 PM
Schindlabua
Schindlabua - avatar
+ 3
first of all a method is a function but all function are not method by default . The difference rely on the way you call them and declare them .For our traditional function their declaration and call is very simple and all of us know how to do it..With method the particularity is that you can declare it inside an object only or class and their call is through instance of that class..
17th Nov 2017, 2:18 AM
MONSIEUR GNETO
MONSIEUR GNETO - avatar
+ 1
it's the same but we usually call functions methods for objects
19th Jun 2016, 5:14 AM
hani chrife
hani chrife - avatar
+ 1
understand it lyk this..- methods are functions of objects only.!! and functions are just like functions in C ir C++
7th Jul 2016, 12:29 PM
yash
+ 1
It's semantics and has to do with what you are trying to express. In javascript every function is an object. An object is a collection of key:value pairs. If a value is a primitive (integer, string, boolean), or another object, the value is considered a property. If a value is a function, it is called a 'method'. Within the scope of an object, a function is referred to as a method of that object. It is invoked from the object namespace 'MyObj.theMethod()'. Since we said a function is an object, a function within a function is considered a method of that function. You can say I am going to use the save method of my object. Or you could say, "the save method accepts a function as a parameter". But you generally wouldn't say a function accepts a method as a parameter.
9th Jan 2017, 7:30 AM
InderBole
InderBole - avatar
+ 1
Method: are usually in classes. Functions: Have independent existence.
7th Sep 2017, 8:50 AM
ರಾಜ್
ರಾಜ್ - avatar
0
an object it's a representation of "something" in real world, e.g a Person it's an object, and "walk" a method
26th Aug 2016, 3:28 AM
Oscar Fernandez
Oscar Fernandez - avatar
0
very simple To comprehend .think object as container of named variable .When this variable is a function it is called a method
27th Jan 2017, 6:08 PM
Marshial Dominik
Marshial Dominik - avatar
- 4
can you help me?
21st Jun 2016, 1:23 PM
Terence John J. Morilao
Terence John J. Morilao - avatar