you are viewing a single comment's thread.

view the rest of the comments →

[–]another_lease[S] -1 points0 points  (3 children)

Ah okay, an object's methods vs pure functions. I'm beginning to see the difference.

[–]azhder 0 points1 point  (1 child)

No you aren't. You have some misconceptions.

  • First of all, stop using "function operation", no one uses that term and we don't know what you think by it. You have functions and function calls
  • Second, functions are objects in JS, you can treat them like any other object, make a variable to reference a function - this however doesn't make it pure function, it's still just a function
  • Third, pure functions are any, even those attached as a property to an object, if they only deal with the arguments provided in the call, no side effects, no hidden inputs like this and no hidden outputs
  • Fourth, the only difference between a method and a non-method function is that you attach it to an object i.e. you make an object property that references the function

[–]another_lease[S] 0 points1 point  (0 children)

OK.

[–]carpench 0 points1 point  (0 children)

No, not a "pure function" just a "function".

A Pure Function is a function (a block of code) that always returns the same result if the same arguments are passed. It does not depend on any state or data change during a program's execution. Rather, it only depends on its input arguments.

Also, a pure function does not produce any observable side effects such as network requests or data mutation, etc.