+ 6

Difference between function and method in Java script?

I just started learning js and bit confused about this question....u guyz give me the correct explanation.

1st Dec 2018, 1:37 PM
Nida
Nida - avatar
6 Answers
+ 3
a method is an action that is performed on object. eg) var obj = "Hello World!!"; var objLength = obj.length; //length is method here a function is a block of code that is defiend using the function keyword and is executed when it is invoked. eg)invokingFunction(); function invokingFunction() { alert("hello world!!"); }
1st Dec 2018, 2:35 PM
Rishi Anand
Rishi Anand - avatar
+ 3
Method is a function, that belongs only for a certain object.
23rd Feb 2019, 10:24 AM
Seb TheS
Seb TheS - avatar
+ 1
Function is a series of statements required to perform a specific task while methods are tasks associated with an object.Hope that helps..
3rd Dec 2018, 10:24 AM
winnie
winnie - avatar
0
Una funcion devuelve un valor y no debe comunicarse con el usuario, es decir, no puede escribir ni leer de teclado. Se comunica con el metodo main mediante parametros. Una funcion sirve principalmente para calcular Un pricedimiento si puede leer y escribir , por lo tanto puede comunicarse con el usuario. El procedimiento realiza una accion, no devuelve ningun dato
10th Dec 2018, 1:36 PM
ELENA GARCIA DIAZ
ELENA GARCIA DIAZ - avatar
0
A function returns a value and it should not communicate with the programmer. It should not read from the board. It comunicates with the main method trough parameters. His main function is calculate. A procedure should read and write from the board. Therefore it should communicate with the user. The procedure makes and action and doesn't return anything.
10th Dec 2018, 2:11 PM
ELENA GARCIA DIAZ
ELENA GARCIA DIAZ - avatar
0
Method is the function which run under object's hence gets its context (properties and other methods).
15th Dec 2018, 2:01 AM
Gray
Gray - avatar