SitePoint Sponsor

User Tag List

Results 1 to 11 of 11
  1. #1
    SitePoint Mentor silver trophybronze trophy

    Join Date
    Feb 2008
    Location
    Preston, Lancashire
    Posts
    1,376
    Mentioned
    72 Post(s)
    Tagged
    1 Thread(s)

    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,
    Sega
    follow me on ayyelo, Easy WordPress; specializing in setting up themes!

  2. #2
    Mazel tov! bronze trophy kohoutek's Avatar
    Join Date
    Aug 2004
    Location
    Hamburg, Germany
    Posts
    4,248
    Mentioned
    30 Post(s)
    Tagged
    0 Thread(s)
    Some links:

    http://www.codecademy.com/
    https://developer.mozilla.org/en-US/learn/javascript
    http://eloquentjavascript.net/

    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.
    Maleika E. A. | Rockatee | Twitter | Dribbble



  3. #3
    SitePoint Mentor silver trophybronze trophy

    Join Date
    Feb 2008
    Location
    Preston, Lancashire
    Posts
    1,376
    Mentioned
    72 Post(s)
    Tagged
    1 Thread(s)
    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.
    follow me on ayyelo, Easy WordPress; specializing in setting up themes!

  4. #4
    SitePoint Mentor silver trophybronze trophy

    Join Date
    Feb 2008
    Location
    Preston, Lancashire
    Posts
    1,376
    Mentioned
    72 Post(s)
    Tagged
    1 Thread(s)
    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.
    follow me on ayyelo, Easy WordPress; specializing in setting up themes!

  5. #5
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,527
    Mentioned
    84 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by Sega View Post
    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.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  6. #6
    SitePoint Mentor silver trophybronze trophy

    Join Date
    Feb 2008
    Location
    Preston, Lancashire
    Posts
    1,376
    Mentioned
    72 Post(s)
    Tagged
    1 Thread(s)
    @paul_wilkins ;

    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.
    follow me on ayyelo, Easy WordPress; specializing in setting up themes!

  7. #7
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,527
    Mentioned
    84 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by Sega View Post
    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.
    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.

    Code:
    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.

    Code:
    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.


    Code javascript:
    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:

    Code javascript:
     
    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.');
    Last edited by paul_wilkins; Apr 21, 2012 at 07:15.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  8. #8
    SitePoint Mentor silver trophybronze trophy

    Join Date
    Feb 2008
    Location
    Preston, Lancashire
    Posts
    1,376
    Mentioned
    72 Post(s)
    Tagged
    1 Thread(s)
    @paul_wilkins ;

    It's free ^.^ and hopefully it will get me to the level needed to understand many concepts.
    follow me on ayyelo, Easy WordPress; specializing in setting up themes!

  9. #9
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,527
    Mentioned
    84 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by Sega View Post
    @paul_wilkins ;

    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.
    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.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  10. #10
    SitePoint Mentor silver trophybronze trophy

    Join Date
    Feb 2008
    Location
    Preston, Lancashire
    Posts
    1,376
    Mentioned
    72 Post(s)
    Tagged
    1 Thread(s)
    @paul_wilkins ;

    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.
    follow me on ayyelo, Easy WordPress; specializing in setting up themes!

  11. #11
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,527
    Mentioned
    84 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by Sega View Post
    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?
    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.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •