What is this syntax?

These are the first few lines in the MicrosoftAjax.debug.js file.

What do they do with the syntax? In particular, line 3.

Function.__typeName = 'Function'; Function.__class = true; Function.createCallback = function Function$createCallback(method, context) { 
+4
source share
1 answer

This is regular code that has the $ character in the function name.

function Function$createCallback(method, context) { ... } expression function Function$createCallback(method, context) { ... } is a named function expression; it evaluates a function called Function$createCallback .
Unlike many languages, the $ symbol is completely legal in a Javascript identifier (see JQuery), so this is a normal function with a somewhat unusual name.

The code assigns this function to create the createCallback property on the Function object.
(The property is a function, Javascript functions are no different from variables)

+3
source

Source: https://habr.com/ru/post/1337409/


All Articles