Why the link for the function is not createdf
f
if ( function f() { } ) { console.log( typeof f ); } // result: undefined
While the assignment / setting variable works fine insideif( )
if( )
if ( f = 'assigned' ) { console.log( typeof f ); } // result: string
I need to know that what happens in the first case, as the second case works as expected
Can someone explain please?
As you put function f() { }in the context of an expression, this is a named function expression, not a function declaration.
function f() { }
, , , f, f (), , .
// Global scope function a() { // a is a function declaration and creates a variable called a to which the function is assigned in the scope (global) that the declaration appears in function b() { // b is a function declaration and creates a variable called a to which the function is assigned in the scope (function a) that the declaration appears in } var c = function d() { // c is a variable in the scope of the function b. The function d is assigned to it explicitly // d is a function expression and creates a variable called d to which the function is assigned in the scope (function d) of itself }; }
Source: https://habr.com/ru/post/1695489/More articles:How to get contents of Redux repository in console without devtools? - javascriptRMarkdown Chunk - не отражать последнее выражение - rSmooth and group complex objects in Linq and save zero children - c #Найти исходное имя сообщения, полученного с помощью API-интерфейса RegisterWindowMessage - c++Unable to access protected member of another instance from scope of derived type - c ++Android app with size = null in the Play Store - androidR Tool for Visual Studio - Error: System.ArgumentException: Package does not have ProvideToolWindowAttribute - rHow to add items from a list to nested lists in a data frame one by one - pythonMy pointers and structure code display garbage values - cI have an enumeration in my Typescript / Ember 3.1 application and I get import errors at runtime. What's happening? - ember.jsAll Articles