Let's learn JavaScript

I’ve had many discussions on this forum and I think it would be best for me to learn JS. I wanted to know the best resources to learn. I learn better with video tutorials and my examples. I learn HTML 10-years back through a website called davesite, and it did wonders to me, back then w3c was not very big, if it was at all there.

I think this would be a good stating place for people to learn JavaScript and learn what we embarrassed should have known in the beginning.

Kind regards,

Some links:


Also, we had a SitePoint course awhile ago that was very good. I think the course has moved over to learnable.com. I do recommend it and video tutorials are also included. :slight_smile:

I really like the http://www.codecademy.com/, it’s pretty amazing! I am going to go through that a couple of times. See how it get’s on. I think I have a Sitepoint book somewhere on JS, I think I will get that out and practice too.

I also found this awesome video tutorials set for FREE - http://thenewboston.org/, pretty amazing. =) Trying to keep on topic, why would we use JS. I used to use it in the days of form validation. jQuery is more for animation, if I am correct, and JS was more for form validation. This is a little confusing.

jQuery has a very nice validation plugin that goes with it. The purpose of jQuery is to help deal with browser incompatibilities for you, so that you can get on with doing stuff.

That’s not to say that you should use the jQuery library in preference though. But if you already have jQuery available then it makes sense to make good use of what it can offer.


I will, would you say it’s a good idea to learn JS before JQuery? I know many use jQuery without JS knowledge. I prefer to do things the right way.

I took a quick look and while it does an okay job, there are some issues.

For example with the video that I looked at, #27 on adding methods to objects.

He creates a constructor function but fails to follow the standard convention of capitalising the first letter in its name.
There’s also a matter of semantics going on here too though. The constructor is used to create a single person, so it should be called Person instead of people.

function people(name, age){ // should be Person instead of people
    this.name  = name;
    this.age = age;

Later on he adds this method to the constructor.

function yearsLeft(){
    var numYears =  65 - this.age;
    return numYears;

There’s no need to declare that variable in that function, since it doesn’t add anything more to our understanding of what’s going on.
Instead, the function would do better by being renamed, and just returning the result of the calculation itself.

function yearsToRetirement(){
    return 65 - this.age;

A new problem is that he sets a constructor property to that yearsLeft function from within the constructor itself, when that is better done as a part of the prototype instead. As things currently are, the functions are globally exposed, and every new person will have a new reference to that yearsLeft function. When placing a method on an objects prototype, there is only the one version of that function to worry about.

And he uses document.write() to display information. Aargh!

I’m sorry, that’s just from one 8 minute lesson.

Better code would be:

function Person(name, age) {
    this.name  = name;
    this.age = age;
Person.prototype.retirementAge = 65;
Person.prototype.yearsToRetirement = function () {
    return this.retirementAge - this.age;

var natalie = new Person('Natalie Portman', 28);
window.alert(natalie.name + ' retires in ' + natalie.yearsToRetirement() + ' years.');


It’s free ^.^ and hopefully it will get me to the level needed to understand many concepts.

jQuery is JavaScript. Would you rather use a taxi instead of your own vehicle? It’s a similar comparison.
With a taxi you don’t have to worry as much about how things get done. You instead give some idea of what you want to achieve, and things are done for you. It’s at a cost though, because jQuery can be a large amount of code that’s loaded up, with which to achieve what can be done in just a fraction of its size.


:slight_smile: Thanks for the comparison.

I am still struggling to understand where you would use JS in your website. I use WordPress and it’s working well with me. Most of the things I do involve getting ready made scripts, plug-ins or templates. Where would you use JavaScript?

I was thinking maybe in the custom fields, so you could have something calculate and do something based on that. I think probably this is the best way to use JS in conjunction with WordPress.

That’s the good thing about JavaScript. If you don’t have a need to use it, then you just don’t use it.
It’s preferable to not use JavaScript if you don’t need to, than to use it if you don’t have a need.