If you play with the JSC program, you can perform various calculations and see results: > 1 + 2 3 > "hello" hello The problem is if you attempt to create a variable binding, which does not return a value. In this case, the JSC program reports 'undefined', which is a surprising result and might confuse a user into thinking an error has occurred. For example: > var add2 = function(arg) { return arg + 2; } undefined > add2(15) 17 It seems like it would be better if the transcript looked like the following: > 1 + 2 3 > var add3 = function(arg) { return arg + 3; } > add3(15) 18
The result printed is the result of the expression. While it may seem odd that "var x = 5" displays undefined that is specified behaviour. Not doing so would create even more confusion as eval("var x=5") will correctly display undefined. There's also a reasonable concern that changing this behaviour would break the mozilla js test suite you hit with run-javascriptcore-tests