Live data from Hacker News

How One Missing `var` Ruined our Launch

blog.meloncard.com

221–223 of 223 posts

Re: How One Missing `var` Ruined our Launch

#221
post #3

Am I right in thinking that the javascript /* "use strict" */ construct would have caught this mistake (just like it would have done for me in perl code)? Seems to me that some such feature is absolutely and utterly necessary in any environment where you're doing a lot of closure creation ..

No.

    > var initial = 'string';
    >  "use strict"; (function(){ initial = 'anotherstring' })();
    > initial
    'anotherstring'
    >

Re: How One Missing `var` Ruined our Launch

#222

Ouch. I always thought JS's global-variables-by-default schtick was it's worst crime, but I've never seen such terrible consequences for it up close before. Note to self: before products get to forbes, do some load testing. Even if I am using node, with its magic event loop of invulnerability.

No such thing as "global-variables-by-default".

    > (function () { internalvariablewithnovardelcaration = "string"; })();
    > internalvariablewithnovardeclaration
    ReferenceError: internalvariablewithnovardeclaration is not defined

Re: How One Missing `var` Ruined our Launch

#223

Earlier quoted context omitted.

No IDE needed - any decent editor will do syntax highlighting.

Global versus local variables is not determined by syntax in javascript, it's determined by semantics (you need to parse javascript to find out). A few editors can do that, but you could really call those an IDE already.

Parsing is syntax. Interpretation is semantics. Just parsing JS just gives you information about its syntax, and any decent editor (like vim or emacs) has a programmable interface such that you can write a JS parser.
Post reply on HN