Search code examples
javascriptnotation

What's this "function a/<()" in the developer console?


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:

enter image description here

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.


Solution

  • 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 - inner b of var a = function() { var b = function() {}; }
    • a< - flags a "contributor" or basically some helper function which contributes to the function named a by being anonymous inside it.

    So a/<() means that there is an anonymous function was declared in the body of a.