0

is a function in js == method in java?

7th May 2018, 10:04 PM
hermogenianus
hermogenianus - avatar
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
7th May 2018, 10:15 PM
᠌᠌Code X
᠌᠌Code X - avatar
+ 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?
8th May 2018, 6:45 AM
Meeky
Meeky - avatar