0

editable: params => this.isEditable(applied)(params)

this editable get boolean value by calling iseditable function by passing applied as a paramaters. but params is get passed with it. what is the meaning of this code?

  • One creates a function which does X when you call it. The other just does X now. – Quentin Jul 24 '20 at 07:42
  • Possible duplicate of https://stackoverflow.com/questions/336859/var-functionname-function-vs-function-functionname – Karan Jul 24 '20 at 07:43
  • `this.isEditable(applied)` returns a function. `this.isEditable(applied)(params)` calls `this.isEditable()` and immediately executes the returned function passing it `params` – Andreas Jul 24 '20 at 07:44
  • You might want to have a read: https://medium.com/front-end-weekly/javascript-es6-curry-functions-with-practical-examples-6ba2ced003b1 – Sebastian Kaczmarek Jul 24 '20 at 07:48

1 Answers1

-1

Well, you only showed a small snippet, but I suspect it's something along the lines as

     
    {// Some object is being constructed...
       editable: params => this.isEditable(applied)(params)
    } 

Which is an ES6 "arrow function expression", which returns some other function, as the return value of calling isEditable.

     //Some object is being constructed...
    {
       editable: function ( params ){
              return this.isEditable(applied)(params)
       },
       // More properties being defined...
    } 

You can learn more about ES6 arrow function expressions here https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Arrow_functions

rexfordkelly
  • 1,262
  • 7
  • 12