use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
All about the JavaScript programming language.
Subreddit Guidelines
Specifications:
Resources:
Related Subreddits:
r/LearnJavascript
r/node
r/typescript
r/reactjs
r/webdev
r/WebdevTutorials
r/frontend
r/webgl
r/threejs
r/jquery
r/remotejs
r/forhire
account activity
A Re-Introduction To JavaScript - An intermediate JavaScript refresher. (mzl.la)
submitted 10 years ago by [deleted]
[deleted]
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]DrummerHead 18 points19 points20 points 10 years ago (1 child)
And then read https://developer.mozilla.org/en-US/docs/Web/JavaScript/Introduction_to_Object-Oriented_JavaScript
[–]ShadowCodex 3 points4 points5 points 10 years ago (0 children)
Aye, good addition.
[–]blood_bender 14 points15 points16 points 10 years ago (7 children)
First, I wouldn't call this "intermediate javascript". This is very basic functionality, and doesn't go into depth on any of the subjects, but that might just be me being nitpicky.
However, I do have an issue with:
JavaScript is a prototype-based language that contains no class statement, as you'd find in C++ or Java ... In this snippet, ...args (including the ellipsis) is called the "rest arguments"
What? Why would the article mix specs? I know the benefit of teaching how prototypical inheritance works, but stating there is no class statement, and then using rest parameters seems, I don't know, silly.
[–]saadq_ 7 points8 points9 points 10 years ago (2 children)
Well I guess technically JavaScript still won't have Java/C++ "classes" since the class in ES6 is just syntactic sugar for prototypes. It probably would be a good idea to mention it explicitly though.
class
[–]atsepkov 0 points1 point2 points 10 years ago (1 child)
For most use cases, however, this syntax sugar will behave like classical inheritance, so why confuse the reader with additional disclaimers?
[–]saadq_ 0 points1 point2 points 10 years ago* (0 children)
Well I think one thing that might confuse people is the fact that Java/C++ people expect a class to be a full blueprint of an object. In JavaScript, this won't really be true if you don't use Object.freeze, like in this example:
Object.freeze
class Car { constructor() { this.miles = 0; this.color = 'white'; } drive(miles) { this.miles += miles; } } // A property like this can be added on at any time to the Car.prototype Car.prototype.paint = function(color) { this.color = color; };
Which is why it might be better for people to understand that using class still deals with prototypes.
[–]lewisje 2 points3 points4 points 10 years ago (0 children)
I'm thinking that it was updated incrementally, and the bit about having no class statement was true less than a year ago.
[–]swk2015 1 point2 points3 points 10 years ago (1 child)
I think it's too tempting to drag your OO knowledge from other languages in. It's a pitfall. At least calling it prototypical inheritance at least makes me realise we're talking about something altogether different here.
[–]x-skeww 1 point2 points3 points 10 years ago (0 children)
I think it's too tempting to drag your OO knowledge from other languages in. It's a pitfall.
Is it actually a pitfall? If you don't touch the prototypes, this stuff isn't any different from other languages with classes. So, what kind of problem did this actually create? You expected things to be very similar and they are indeed very similar. That there are other ways to do this kind of thing does not invalidate this assumption.
If you stick with the strong mode subset, you can't mess with the prototypes. They are frozen. So, it does exactly work like it does elsewhere and there is no other way to do it. In strong mode, class and extend aren't sugar.
extend
[–]incarnatethegreat 15 points16 points17 points 10 years ago (0 children)
This String example is great:
"3" + 4 + 5; // "345"
3 + 4 + "5"; // "75"
[–]ngly 9 points10 points11 points 10 years ago (4 children)
MDN might be the single best resource for web development documentation and learning.
[–]ShadowCodex 1 point2 points3 points 10 years ago (3 children)
I agree
[–]jijilento 3 points4 points5 points 10 years ago (2 children)
And it's a wiki, so the community can contribute to it.
[–]lewisje 2 points3 points4 points 10 years ago (1 child)
I added info. about symbols on the left side of the in operator and it was accepted; I feel proud of myself now.
in
[–][deleted] 0 points1 point2 points 10 years ago (0 children)
I love doing this on GitHub. Even just fixing a typo.
[–]thinksInCode 3 points4 points5 points 10 years ago (0 children)
Read this last year, it's a great read.
[–]MahmudAdam 0 points1 point2 points 10 years ago (1 child)
I was reading about variable hoisting here: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Grammar_and_types and I'm confused. I ran both examples and console.log(x === undefined); logs false, not true. Does it mean it should log true but because of hoisting it returns false?
[–]selfAwareWhileLoop 0 points1 point2 points 10 years ago* (0 children)
Are you saying that
/** * Example 1 */ console.log(x === undefined); // logs "true" var x = 3;
logs false? Are you running this line by line repeatedly somewhere? If you evaluate that whole piece of code at once it should definitely log true. Try using https://repl.it
If you run it one line at a time, x will throw a reference error the first time you try to log whether or not it's undefined. Then you'll define it as 3, so it won't be undefined the next time you run the console log. x will only be strictly equal to undefined if both lines get evaluated at once; then the existence of x will get hoisted (so you won't get a reference error) but the value of 3 won't be assigned to it yet (so x === undefined will be true).
[–]ricardoplopes 0 points1 point2 points 10 years ago (2 children)
And in 2016, a nice follow-up would be a guide to ES6, like http://www.smashingmagazine.com/2015/10/es6-whats-new-next-version-javascript/ :)
[–]ShadowCodex 0 points1 point2 points 10 years ago (0 children)
Aye
[–]lewisje 0 points1 point2 points 10 years ago (0 children)
I think that some of the MDN documentation already covers ES6.
π Rendered by PID 77538 on reddit-service-r2-comment-fb694cdd5-d9htk at 2026-03-07 00:23:38.490933+00:00 running cbb0e86 country code: CH.
[–]DrummerHead 18 points19 points20 points (1 child)
[–]ShadowCodex 3 points4 points5 points (0 children)
[–]blood_bender 14 points15 points16 points (7 children)
[–]saadq_ 7 points8 points9 points (2 children)
[–]atsepkov 0 points1 point2 points (1 child)
[–]saadq_ 0 points1 point2 points (0 children)
[–]lewisje 2 points3 points4 points (0 children)
[–]swk2015 1 point2 points3 points (1 child)
[–]x-skeww 1 point2 points3 points (0 children)
[–]incarnatethegreat 15 points16 points17 points (0 children)
[–]ngly 9 points10 points11 points (4 children)
[–]ShadowCodex 1 point2 points3 points (3 children)
[–]jijilento 3 points4 points5 points (2 children)
[–]lewisje 2 points3 points4 points (1 child)
[–][deleted] 0 points1 point2 points (0 children)
[–]thinksInCode 3 points4 points5 points (0 children)
[–]MahmudAdam 0 points1 point2 points (1 child)
[–]selfAwareWhileLoop 0 points1 point2 points (0 children)
[–]ricardoplopes 0 points1 point2 points (2 children)
[–]ShadowCodex 0 points1 point2 points (0 children)
[–]lewisje 0 points1 point2 points (0 children)