Striving to become a master Go/Cloud developer; Father ๐จโ๐งโ๐ฆ; ๐ค/((Full Stack Web|Unity3D) + Developer)/g; Science supporter ๐ฉโ๐ฌ; https://coder.today
Kind of, in JS functions are first class objects, they can have properties and other functions attached, the difference is that this objects can be called ().
When comparing to static OOP languages JS functions are high ranked citizens, you can do crazy stuff with them, now we have lamdba functions too which is more amazing.
But in functional programming functions are first class ..anything, even the operators are functions
Functions in Javascript are first-class. Period. The ability to model them as objects with instance members is not relevant. The fact that Javascript separates the notion of operators and functions does not have any relevance either. Nor does the ES6 lambda syntax. Javascript has always had first-class anonymous functions! Semantically, it's not recent at all.
The term first class is well-defined in our field. If you look it up and test each requirement against the capabilities of functions in Javascript, you will see that they are indeed first class.
Striving to become a master Go/Cloud developer; Father ๐จโ๐งโ๐ฆ; ๐ค/((Full Stack Web|Unity3D) + Developer)/g; Science supporter ๐ฉโ๐ฌ; https://coder.today
This is what I usually say too, but there is no period, if you learn more advanced topics you find out that everything in JS is an object. You cannot just say is not relevant (like you say), is very relevant on THIS topic, when you compare the language to Functional Programming ones.
JS -> everything is an object
FP -> everything is a function
You can loosely say that functions are prime citizens in JS and in FP languages, but ... we have to differentiate them to a degree, world is not white and black like you say, there are many grey nuances.
In JavaScript, functions are first-class objects, because they can have properties and methods just like any other object. What distinguishes them from other objects is that functions can be called. In brief, they are Function objects. -- MDN documentation
Also Arrow (lambda called in other languages) functions are not anonymous functions, they have different implementations and effects. Anonymous is just a function without a name (which is not recommended anyway because it's harder to debug).
We are talking in circles here. Your quote is saying nothing of relevance. The ability to furnish a function with properties and methods that operate upon them does not matter at all.
Let me make this really clear.
You say: "methods [Functions] are not prime [first-class] citizens"
You are wrong.
Functions in Javascript conform to all of the requirements that make a construct first-class in a programming language.
If you still want to disagree this with, please provide a concrete example demonstrating how functions are not first-class in Javascript.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Kind of, in JS functions are first class objects, they can have properties and other functions attached, the difference is that this objects can be called ().
When comparing to static OOP languages JS functions are high ranked citizens, you can do crazy stuff with them, now we have lamdba functions too which is more amazing.
But in functional programming functions are first class ..anything, even the operators are functions
and you can overload them
and many other things I do not understand yet :)
Functions in Javascript are first-class. Period. The ability to model them as objects with instance members is not relevant. The fact that Javascript separates the notion of operators and functions does not have any relevance either. Nor does the ES6 lambda syntax. Javascript has always had first-class anonymous functions! Semantically, it's not recent at all.
The term first class is well-defined in our field. If you look it up and test each requirement against the capabilities of functions in Javascript, you will see that they are indeed first class.
This is what I usually say too, but there is no period, if you learn more advanced topics you find out that everything in JS is an object. You cannot just say is not relevant (like you say), is very relevant on THIS topic, when you compare the language to Functional Programming ones.
JS -> everything is an object
FP -> everything is a function
You can loosely say that functions are prime citizens in JS and in FP languages, but ... we have to differentiate them to a degree, world is not white and black like you say, there are many grey nuances.
Also Arrow (lambda called in other languages) functions are not anonymous functions, they have different implementations and effects. Anonymous is just a function without a name (which is not recommended anyway because it's harder to debug).
We are talking in circles here. Your quote is saying nothing of relevance. The ability to furnish a function with properties and methods that operate upon them does not matter at all.
Let me make this really clear.
You say: "methods [Functions] are not prime [first-class] citizens"
You are wrong.
Functions in Javascript conform to all of the requirements that make a construct first-class in a programming language.
If you still want to disagree this with, please provide a concrete example demonstrating how functions are not first-class in Javascript.