Javascript Constructors and Prototypes
tobyho.com
Javascript Constructors and Prototypes
1–10 of 55 posts
Re: Javascript Constructors and Prototypes
#2While I was looking at the JavaScript code my brain almost exploded.
Re: Javascript Constructors and Prototypes
#3SomeClass.prototype.someMethod
Which outputs the methods source. Then you can add some debug code like console.log(xxx) or even fix a simple bug, copy the whole thing and set it again:
SomeClass.prototype.someMethod = function ...
Voila! Hot code push without an IDE. While that's obviously not ideal, it certainly works in some cases.
Re: Javascript Constructors and Prototypes
#4I used the prototype mechanism several times when debugging a script that I couldn't easily change source code for. I just typed: SomeClass.prototype.someMethod Which outputs the methods source. Then you can add some debug code like console.log(xxx) or even fix a simple bug, copy the whole thing and set it again: SomeClass.prototype.someMethod = function ... Voila! Hot code push without an IDE. While that's obviously…
Re: Javascript Constructors and Prototypes
#5I wanted to read this because I believe it's a great article, but the fact that he doesn't use semicolons pretty much turned me off. While I was looking at the JavaScript code my brain almost exploded.
http://mislav.uniqpath.com/2010/05/semicolons/
Not reading an article because of that would be like not reading other code because it uses 2 spaces for tabs instead of 4. Makes no difference to the language, only to you.
Re: Javascript Constructors and Prototypes
#6I wanted to read this because I believe it's a great article, but the fact that he doesn't use semicolons pretty much turned me off. While I was looking at the JavaScript code my brain almost exploded.
Did you see the article he linked about why he doesn't use them? http://mislav.uniqpath.com/2010/05/semicolons/ Not reading an article because of that would be like not reading other code because it uses 2 spaces for tabs instead of 4. Makes no difference to the language, only to you.
It's now 404ing, but there was a pretty well-known argument on one of Twitter Bootstrap's GitHub issues[1]. The Bootstrap guys didn't use semicolons, and it caused problems when minifying the code. It's an edge case, I know, but it was a problem.
I never understood the whole anti-semicolon thing anyway. It just seems really hipster to me. Use CoffeeScript, if you don't want semicolons.
[1] https://github.com/twitter/bootstrap/issues/3057Re: Javascript Constructors and Prototypes
#7Earlier quoted context omitted.
Did you see the article he linked about why he doesn't use them? http://mislav.uniqpath.com/2010/05/semicolons/ Not reading an article because of that would be like not reading other code because it uses 2 spaces for tabs instead of 4. Makes no difference to the language, only to you.
The thing is, semicolons do make a difference with JavaScript. It's now 404ing, but there was a pretty well-known argument on one of Twitter Bootstrap's GitHub issues[1]. The Bootstrap guys didn't use semicolons, and it caused problems when minifying the code. It's an edge case, I know, but it was a problem. I never understood the whole anti-semicolon thing anyway. It just seems really hipster to me. Use CoffeeScript…
I understand that using existing minifiers is a possible reason to use semicolons, but not using semicolons is not an inherent issue here.
Re: Javascript Constructors and Prototypes
#8I wanted to read this because I believe it's a great article, but the fact that he doesn't use semicolons pretty much turned me off. While I was looking at the JavaScript code my brain almost exploded.
Did you see the article he linked about why he doesn't use them? http://mislav.uniqpath.com/2010/05/semicolons/ Not reading an article because of that would be like not reading other code because it uses 2 spaces for tabs instead of 4. Makes no difference to the language, only to you.
The author was actually annoying me by the time I reached "It's good coding style".
One example:
> My advice on JSLint: don’t use it. Why would you use it? If you believed that it helps you have less bugs in your code, here’s a newsflash; only people can detect and solve software bugs, not tools. So instead of tools, get more people to look at your code.
Pretty sure lots of people use JSLint, pep8 checkers, gofmt, or whatever the equivalent tool for the language at hand is. They certainly help, one cannot deny that.
Then the author goes on to pick at Crockford for suggesting people space their JS with four spaces… Yep, I'm done.
Re: Javascript Constructors and Prototypes
#9Earlier quoted context omitted.
Did you see the article he linked about why he doesn't use them? http://mislav.uniqpath.com/2010/05/semicolons/ Not reading an article because of that would be like not reading other code because it uses 2 spaces for tabs instead of 4. Makes no difference to the language, only to you.
The thing is, semicolons do make a difference with JavaScript. It's now 404ing, but there was a pretty well-known argument on one of Twitter Bootstrap's GitHub issues[1]. The Bootstrap guys didn't use semicolons, and it caused problems when minifying the code. It's an edge case, I know, but it was a problem. I never understood the whole anti-semicolon thing anyway. It just seems really hipster to me. Use CoffeeScript…
However, needing to understand the rules is one thing - I much prefer to see the semi-colons in there. I dislike seeing any formatting that is substantially different from the accepted norm and find it harms readability.