+ 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.
6 odpowiedzi
+ 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!!");
}
+ 3
Method is a function, that belongs only for a certain object.
+ 1
Function is a series of statements required to perform a specific task while methods are tasks associated with an object.Hope that helps..
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
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.
0
Method is the function which run under object's hence gets its context (properties and other methods).