is any JavaScript statement an expression?
functional-programming, javascript
Solution
I'd say no, as you can't use just any statement where an expression is expected:
// SyntaxError: Unexpected token var
var a = var b;
// SyntaxError: Unexpected token if
var c = if (true) {};
The `undefined` shown in Chrome's console is due to its use of `eval()` (or a native/internal equivalent), which evaluates any code:
var a = eval('var b;');
console.log(a); // undefined
The `undefined` isn't the result of `var b;`, but because `eval()` itself still has a return value -- whether the evaluated code supplied it or not.
Problem
I know that functional languages like Lisp don't have statements. Everything there is an expression. JavaScript is a functional language. So I came to a conclusion that every JavaScript statement is an expression. This thought came to my mind when I was playing with chrome's console. Every statement entered there is evaluated and the console returns undefined if an expression doesn't return certain value.