Skip to content
Advertisement

how to pass variables to method

I want to pass variables to the method. which of the following is better? (x and y are constants)

JavaScript

or:

JavaScript

Advertisement

Answer

I’d argue the second one is better with regards to function purity, though this is a principle of Functional Programming rather than Object Oriented Programming. The only thing I’d wonder then is why you’d even make it a member method at all, instead of a stand-alone function.

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement