11 ms·
A Simple, Comprehensive Overview of Javascript
- Oculus 13y agoI think a really good addition to the blog post would be a link to an article/blog post that explains more in-depth the different topics shown. For instance, when you discussed Objects, a link to http://javascriptissexy.com/javascript-objects-in-detail/ http://javascriptissexy.com/javascript-objects-in-detail/ would have been very useful. Javascript has a lot of weird edge cases and peculiarities that newcomers should read about. Other than that, awesome post. I always love just seeing the code vs. reading about it in a book. I find it's easier to learn that way, especially when the language you're coming from has a lot of similarities. EDIT: To clarify, I have no affiliation with 'JS is Sexy', I just think the lessons/tutorials Richard Bovell writes are awesome!
- kalid 13y ago(Author here) Thanks for the feedback! I originally wrote this in 2007 when I was diving into Javascript to build instacalc.com. I agree with the examples vs. trying to read in a book. Books often get in their own way, trying to overgeneralize: just show me the code! If I already know how to program, having 5-10 reference examples of every language feature should be enough. You don't need to explain what a conditional is, etc. I'll put in a link to that object deep dive :).
- shtylman 13y agoDon't throw strings. Use the Error object.
- jimmaswell 13y agoI don't see why it really matters most of the time, especially in one-off javascript scripts.
- strager 13y agoError objects have stack traces in modern engines, which is very helpful for debugging. Strings do not.
- jimmaswell 13y agoThat seems like poor design on the engines' part.
- shtylman 13y agoBecause someone will come along and copy and paste your broken code and put it into something else and now more people have to deal with it. Just take the steps to make it not suck from day 1 :)
- ororlrlrlylyly 13y agoMulti-line strings are non-standard.
- semiprivate 13y agoSimple and Comprehensive? Aren't those opposites in this case?
- jimmyhchan 13y agotypeof is an operator not a function
- tellnes 13y agoEval is evil. Don't pass a string as first argument to setTimeout.
- camus 13y agoBut if you really need eval ( i do sometimes yes ) , use scoped evals with a function constructor. var myEval = new Function("my().stuff().to().eval();"); myEval();
- laurent123456 13y ago> parseInt("123") // base 10 => 123 The radix is not always 10 by default, it's implementation dependent and sometime it even depends on the number to be parsed. "8" will be parsed in base 10, "08" in base 8. Always specify the radix [1] [1] https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/parseInt https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...
- kevinjhc 13y agoIn "Javascript Classes," is the public function self.setName supposed to be this.setName?
- camus 13y ago> Redirect if javascript disabled: <noscript><meta http-equiv="refresh" content="0; URL=http://example.com/noscript.html"/></noscript> http://example.com/noscript.html"/></noscript> Dont do that, redirect when javascript IS enabled(if it is a SPA). or you'll take a huge SEO hit. your website should be usable without javascript anyway. the SPA itself doesnt care about SEO because it is not crawlable anyway.