0
is a function in js == method in java?
2 Answers
+ 4
i hope you realise JavaScript also has methods.I get your point anyways,java calls every function whether its a property of an object or not a method so you can say yes
+ 1
JavaScript Function and java methods functions in same way, but they are basically different and the difference is in the context where they are used.
We can say a function is a piece of code that can stand alone on its own while a method is a function that is defined within the context of a class, or anything that has the characteristics of a class.
So we can say all methods are functions but not all functions are methods.
In java you donât have a âfunctionâ simply because all functions are defined within a class, hence methods, in java script you can write and invoke a function anywhere, but in JavaScript all functions defined inside a class are called methods.
Hope this helps?