L
Lawrence San
According to a JavaScript debugger (Firebug), and to a JS lint, this is
fine:
function recalc(){deriv = 6;} [more code here]
But, if I've assigned the function to a variable like this:
var bells = function recalc(){deriv = 6;} [more code here]
.... then both the debugger and the lint report an error, saying there's
a missing semicolon after the close-curly-brace. They say I should do
this:
var bells = function recalc(){deriv = 6;}; [more code here]
They must be right, because the code works the second way but not the
first way. But why? Isn't a close-curly-brace supposed to be sufficient
to indicate the end of a statement? Usually, if you put a semicolon
after a close-curly-brace like this:
function recalc(){deriv = 6;}; [more code here]
....the lint complains "Warning: empty statement or extra semicolon".
But if the beginning of the statement includes a variable assignment,
it wants the extra semicolon at the end. Why?
fine:
function recalc(){deriv = 6;} [more code here]
But, if I've assigned the function to a variable like this:
var bells = function recalc(){deriv = 6;} [more code here]
.... then both the debugger and the lint report an error, saying there's
a missing semicolon after the close-curly-brace. They say I should do
this:
var bells = function recalc(){deriv = 6;}; [more code here]
They must be right, because the code works the second way but not the
first way. But why? Isn't a close-curly-brace supposed to be sufficient
to indicate the end of a statement? Usually, if you put a semicolon
after a close-curly-brace like this:
function recalc(){deriv = 6;}; [more code here]
....the lint complains "Warning: empty statement or extra semicolon".
But if the beginning of the statement includes a variable assignment,
it wants the extra semicolon at the end. Why?