functional programming - is any JavaScript statement an expression? -
i know functional languages lisp don't have statements. there expression. javascript functional language. came conclusion every javascript statement expression. thought came mind when playing chrome's console. every statement entered there evaluated , console returns undefined if expression doesn't return value.
i'd no, can't use statement expression expected:
// syntaxerror: unexpected token var var = var b;
// syntaxerror: unexpected token if var c = if (true) {};
the undefined
shown in chrome's console due use of eval()
(or native/internal equivalent), evaluates code:
var = eval('var b;'); console.log(a); // undefined
the undefined
isn't result of var b;
, because eval()
still has return value -- whether evaluated code supplied or not.
Comments
Post a Comment