I personally prefer programming guides with some humor, lots of examples and exercises. That's why I recommend Eloquent Javascript by Marijn Haverbeke. http://eloquentjavascript.net/
I agree. Eloquent Javascript is excellent.
The best JavaScript guide ever
11–20 of 56 posts
Re: The best JavaScript guide ever
#12Earlier quoted context omitted.
I agree. Eloquent Javascript is excellent.
At least in Google Chrome on a Mac, all I get are blank white pages. If I hit view source, then I see text, but otherwise I see no text.
Re: The best JavaScript guide ever
#13The best way I've found to learn JavaScript is through anything by Douglas Crawford. 'JavaScript the Good Parts' is especially good. http://oreilly.com/catalog/9780596517748 http://www.youtube.com/watch?v=hQVTIJBZook
I also strongly recommend his work for a better understanding of Javascript.
Re: The best JavaScript guide ever
#14I personally prefer programming guides with some humor, lots of examples and exercises. That's why I recommend Eloquent Javascript by Marijn Haverbeke. http://eloquentjavascript.net/
Re: The best JavaScript guide ever
#15My goal was to return something like {x:1} (an object) from a script. It never worked. If I type that into a console, it returns "1". If I type x:1 into the console, it also returns 1. So I guess the "{}" is just interpreted as a block, returning the value of the x:1 expression. But what does x:1 mean? I am guessing it might just be a bug in the interpreter? Or when is something an object, and when just a block? var a = x:1 doesn't work, btw. this.x is also still undefined after this.
The only way I could return my wanted object was by doing var y = {x:1};y;
(This was supposed to be the return value of a Script in NodeJS, using these silly values because it was a unit test).
Re: The best JavaScript guide ever
#16It is not a tutorial. It's a reference guide.
...and yet it has 17 points only being posted 16 minutes ago. Is PG working at all on an algorithm that takes into consideration factors such as the repetition with which certain accounts vote up a link (or a group of accounts) and inversely weigh that against other links sumbitted? Possibly implementing the results via the Fisher Method / Bayesian rank of some kind? As the noise to signal ratio has widened with HN's…
Re: The best JavaScript guide ever
#17While we are at it, perhaps somebody could explain this JS gotcha I recently ran into? My goal was to return something like {x:1} (an object) from a script. It never worked. If I type that into a console, it returns "1". If I type x:1 into the console, it also returns 1. So I guess the "{}" is just interpreted as a block, returning the value of the x:1 expression. But what does x:1 mean? I am guessing it might just b…
function asdf(){
return {x:1};
}
It's a less verbose way of doing this: function asdf2(){
var myObj = new Object();
myObj.x = 1;
return myObj;
}
Outside of a object written in shorthand notation, x:1 is treated as a label (x:) followed by a value (1). In general labels are not used in JS, and it's probably a good idea to avoid them.Relatedly, to "fake" a block in JS, wrap it in a function:
(function(){
var a = 1;
// do something with a
}());
// out side of the "block" a is undefined (or whatever value it was before the "block")
[Edited for accuracy and clarity]Re: The best JavaScript guide ever
#18Earlier quoted context omitted.
Good point. I'll update the title. [edit] title updated
Please read http://ycombinator.com/newsguidelines.html and edit accordingly. Something like "The Mozilla Developer Center's JavaScript Guide" would be a good title.
Re: The best JavaScript guide ever
#19While we are at it, perhaps somebody could explain this JS gotcha I recently ran into? My goal was to return something like {x:1} (an object) from a script. It never worked. If I type that into a console, it returns "1". If I type x:1 into the console, it also returns 1. So I guess the "{}" is just interpreted as a block, returning the value of the x:1 expression. But what does x:1 mean? I am guessing it might just b…
var a = x:1
This is invalid. Stop guessing. Read the language spec. Best by far is "Definitive Javascript O'Reilly"{} is a block of statements. For example,
{doSomething();doAnotherThing()}
{} when used as an expression, is object literal notation. For example, var a = {foo:23,bar:99};
If you want to be explicit that something is an expression, enclose it in parenthesis... Console>{foo:1}
1 // "{}" = code block, "foo:" = label.
Console>({foo:1})
{foo:1}
Return an object: function foo() {
return {bar:23, baz: function() {return 89}};
}Re: The best JavaScript guide ever
#20Earlier quoted context omitted.
Please read http://ycombinator.com/newsguidelines.html and edit accordingly. Something like "The Mozilla Developer Center's JavaScript Guide" would be a good title.
I think the title is fine as it is now ... makes it clear that this isn't just another JavaScript guide/tutorial.
Noting in the title that this is Mozilla's JS reference is enough to give it credence and is still objective.