javascript - While assigning a function to a variable in JS, why does it gets executed automatically? -


i come python background, , partially understand concept of functions being first class objects in python , javascript.

but behaviour looks unusual me:

$ node > function calc(){console.log('hey');}; > var = calc() hey 

the () in sample [var = calc();] means want invoke function.

if want assign function variable should -

var = calc; 

then, if want invoke can use

a(); 

Comments

Popular posts from this blog

c - How to retrieve a variable from the Apache configuration inside the module? -

c# - Constructor arguments cannot be passed for interface mocks -

python - malformed header from script index.py Bad header -