Visual Studio 2008 “Format Document/Selection” command and a function named “assert” in JavaScript c
Posted
by AGS777
on ASP.net Weblogs
See other posts from ASP.net Weblogs
or by AGS777
Published on Thu, 01 Apr 2010 09:32:00 GMT
Indexed on
2010/04/01
10:03 UTC
Read the original article
Hit count: 598
JavaScript
|Visual Studio
Just have found some funny behavior of the Visual Studio 2008 editor. Sorry if it is already well known bug.
If you happened to have a JavaScript function named “assert” in your code (and there is pretty high likelihood in my opinion), for example something like:
function assert(x, message) { if (x) console.log(message); }
then when either Format Document (Ctrl + K, Ctrl + D) or Format Selection (Ctrl + K, Ctrl + F) command is applied to the document/block containing the function, the result of the formatting will be:
functionassert(x, message) {
if (x) console.log(message);
}
That’s it. function and assert are now joined into one solid word.
So be aware of the fact in case you suddenly start receiving strange exception in your JavaScript code: missing ; before statement functionassert(x, message)
And no, it is not an April Fool's joke. Just try for yourself.
© ASP.net Weblogs or respective owner