While playing with the Developer Console in Firefox, I tried doing this:
var a = b => c => c;
and then this:
a(1)
I expected the result to be function()
(corresponding to c => c
), but this was displayed instead:
function a/<()
What is the meaning of this expression? It clearly isn't legal Javascript, since neither /
nor <
are valid characters for a function name.
The same happens using the regular notation for functions, i.e. var a = function(b) { return function(c) { return c; } }
.
Here is a screenshot:
Edit: I tried the following
var a = b => c => d => d;
a(1)
and the result is
a/</<()
which makes me think it's some kind of lesser-known shorthand notation.
Named Functions: In JavaScript, named functions are simply a way of referring to a function that employs the function keyword followed by a name that can be used as a callback to that function. Normal functions with a name or identifier are known as named functions.
You can check for a function using the typeof keyword, which will return "function" if given the name of any JavaScript function.
Commenters on the relative issue on bugzilla have pointed out that it's part of a naming convention for anonymous function.
In particular,
a/b
- innerb
ofvar a = function() { var b = function() {}; }
a<
- flagsa
"contributor" or basically some helper function which contributes to the function nameda
by being anonymous inside it.
So a/<()
means that there is an anonymous function was declared in the body of a
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With