Missing semi-colon in JavaScript causing “'foo' is undefined” error in IE9-Record and share programming errors
Unfortunately, JavaScript does not require you to explicitly put in semi-colons everywhere that there should be one – but it will internally put those in for you. This can often lead to hard to trace bugs and unexpected behavior.
Among other syntax errors in your code (as others have pointed out), the ;
after the while
in a do-while
is required and when you put in there, things work as you expect them to. When this isn’t done, it’s pretty much impossible for the casual developer to predict how different environments will behave without digging deep into the specs of the language and the JS engine and understanding it all – assuming there are no bugs in the implementation of the JS engine itself. Little things such as whether you have braces ( {
and }
) in the same line or not can make a difference.
Originally posted 2013-08-31 08:09:53.