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++ - llvm function pass ReplaceInstWithInst malloc -

java.lang.NoClassDefFoundError When Creating New Android Project -

Decoding a Python 2 `tempfile` with python-future -