Delving into JS

@Dormilich, @felgall
You two take a keyword: prototype and mistake this for a design pattern: prototypal.
Javascript design patterns here: http://addyosmani.com/resources/essentialjsdesignpatterns/book/#designpatternsjavascript

Adding classical inheritance design patterns to ES6 is not to make things easier for some programmers, that’s an insulting assumption BTW, it is to qualify javascript as a serious, enterprise-level programming language. Something Typescript is trying to do also.

since when are Design Patterns restricted to class-based implementations?

example: the Singleton Pattern

window.singleton = {
    someProperty: 'some value',
    someMethod: function () {
        // …
    }
};

taken from “Javascript Design Patterns” by Ross Harmes & Dustin Diaz

Whom are you fighting with?The Addy Osmani ebook in my link presents a lot of patterns, including the sigleton one. While PLs have different OOP takes, ES6 also brings modules with it, among other things. It’s good to see JS maturing and aligning with PLs that have had a better startup history and class inheritance is a universal standard. JS is escaping the “odd one out” fame and is turning into a “one with an edge over”.

I read online that fundamental Javascript knowledge should be learned first.

Well… yes and no. I agree with the sentiment that it’s better to have a nuts-and-bolts understanding of JavaScript. That said, JavaScript is a complex language with nuances not found in traditional inheritance-based OOP languages. The learning curve for basic JavaScript isn’t very steep - I learned the basics just as you did, by copying and pasting - but mastery is not a one-off thing. It’s the kind of subject that reveals more and more of itself over the course of years of study and experimentation. There’s no harm in learning jQuery first to start getting practical results quickly. Just remember JavaScript offers many more possibilities than jQuery covers, and don’t neglect to delve into it.

1 Like

When I set up my JavaScript by Example web site to teach JavaScript with about 300 examples of JavaScript code, I found that I could add fairly complete coverage for jQuery to it by adding about a dozen extra example pages with links in each case back to the JavaScript pages with the corresponding functionality. While each jQuery page might cover five to ten different calls, they are all related and the differences are made obvious by looking at the differences in the corresponding native JavaScript code. Since everything jQuery can do is covered by linking back to the equivalent native Javascript example there didn’t seem to be any need for more detailed pages foy jQuery assuming that the person had already learnt all the previously presented JavaScript.

[quote=“felgall, post:47, topic:99388”]Since everything jQuery can do is covered by linking back to the equivalent native Javascript example there didn’t seem to be any need for more detailed pages foy jQuery assuming that the person had already learnt all the previously presented JavaScript.
[/quote]

Good point. jQuery is fairly obvious to anyone who has a grounding in JavaScript.

My point is that it could take a long time to gain enough proficiency in JavaScript to build sophisticated client-side applications that go beyond the run-of-the-mill DOM manipulations that jQuery is suited to. While one can learn the JavaScript equivalent of jQuery capabilities easily, that doesn’t begin to cover what one can do with JavaScript.

As you point out on your site, many developers use hopelessly outdated coding practices. I submit that the idea of JavaScript being only for UI widgets and other eye candy of the kind jQuery excels at is likewise outdated.

I agree… What I currently have as examples on my site still doesn’t fully cover all of the things I’d consider that an intermediate level JavaScripter should know and doesn’t even start to touch on more advanced coding.

Unfortunately, until one reaches at least an intermediate stage, their rudimentary knowledge of JavaScript doesn’t offer any significant practical advantage over knowing jQuery. That may be one reason some people don’t bother to learn JavaScript anymore. I’ve met a lot of incurious people in the IT industry, as odd as that may seem. In particular, I know of one manager who insists that all JavaScript be done in jQuery, as though jQuery covered all of the possibilities of JavaScript.

If you’ve read as many jQuery topics here as I have, you woud know that a lot of jQuery users ask basic questions about “how do I do this?” that they wouldn’t need to ask if they properly understood JavaScript.

For that matter, many of those questions wouldn’t need to be asked if they simply read the jQuery documentation and applied it literally.

1 Like

strong text[quote=“Mittineague, post:51, topic:99388”]
a lot of jQuery users ask basic questions about “how do I do this?”
[/quote]

I have seen lots where they have a dozen or more lines of JQuery they can’t get to work to do something that can be done in two or three lines of JavaScript.

I have also seen lots of people asking how to do something with JQuery that is done with a single JavaScript command.

If the people actually know how to use JQuery properly then they already know JavaScript to an intermediate level as JQuery is just a lot of lines of JavaScript written by someone else and all of the JQuery code follows JavaScript syntax and you still need to be able to wrap the JQuery calls in basic JavaScript to get it to work.

I’m sure we’ve all seen many a dozen or more line of javascript trying to do something that could be done in two or three lines of the same javascript.

jQuery is javascript based API. Learning jQuery is learning javascript. It’s as simple as that. How one learns javascript or jQuery API depends on one’s ability alone, it doesn’t constitute proof whether javascript or jQuery are any more or any less adequate. However, using jQuery first does take away a lot of browser inconsistencies, which makes a good case for using it and focusing on learning the language alone.

I thought there was a call to leave JavaScript vs. jQuery debate alone, right? What gives?

Since you can add JavaScript commands to do anything that JQuery doesn’t directly provide those who use JQuery are only limited to what can be done using JavaScript.

Both are therefore equally adequate when it comes to use.

The simplest way to learn JavaScript without needing to worry about the inconsistencies is to simply learn from a source that gives you the code to handle those inconsistencies. Of course jQuery is one such piece of code.

Learning jQuery once you know JavaScript is no different from learning the methods on the built in objects. Many of the jQuery methods now have direct equivalents as much of the additional functionality JQuery originally provided is now available directly in JavaScript (but jQuery provides the polyfills without your needing to add them yourself).

Good point. Since the topic is pretty much trashed it’s time to close it before any more members post any more personal attacks.