SitePoint Sponsor

User Tag List

Page 1 of 2 12 LastLast
Results 1 to 25 of 46
  1. #1
    ********* Articles ArticleBot's Avatar
    Join Date
    Apr 2001
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Discussion thread for JavaScript Object-Oriented Programming Part 1

    This is a dedicated thread for discussing the SitePoint article 'JavaScript Object-Oriented Programming Part 1'

  2. #2
    Anonymous
    SitePoint Community Guest
    Wonderful!!

  3. #3
    Anonymous
    SitePoint Community Guest
    Thank you for this very good and well explained lesson.

    I'm a beginer in Web programming and I have worked with Java.

  4. #4
    Anonymous
    SitePoint Community Guest
    It is a good brief introduction to Javascript object oriented programming. thank you

  5. #5
    Anonymous
    SitePoint Community Guest
    It is very clear explaination. I can't wait for part 2.

  6. #6
    Anonymous
    SitePoint Community Guest
    do you have a "total tutorial" out somewhere? I enjoyed this one I wish i had you as an instructor!

  7. #7
    Anonymous
    SitePoint Community Guest
    wow, create objects in JS, who knew. Very good introduction!!!

  8. #8
    Anonymous
    SitePoint Community Guest
    Very well explained! Thanks a lot.


  9. #9
    Anonymous
    SitePoint Community Guest
    I have been programming with JavaScript for a long time and am pretty-much my office's "resident expert" on the subject. I knew about JavaScript's object-oriented-like abilities, but the need hadn't arisen for them before. Suddenly I was faced with a challenge that seemed to call for just that and I found this article. It helped me tremendously. Thanks!

  10. #10
    Anonymous
    SitePoint Community Guest
    Good one. Very clear.

  11. #11
    SitePoint Enthusiast
    Join Date
    May 2003
    Location
    Poland
    Posts
    89
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    # In JavaScript, there are five primitive data types: Undefined, Null, Boolean, Number, and String.
    # In JavaScript, everything is an object, except for the primitive data types.
    Code:
    var s1 = "test1";
    var s2 = String("test2");
    var s3 = new String("test3");
    
    function test(s) {
        s = "asd";
    }
    
    test(s1);
    alert(s1);
    
    test(s2);
    alert(s2);
    
    test(s3);
    alert(s3);
    
    alert(s1.length);
    alert(s2.length);
    alert(s3.length);
    Primitive types are not objects and cannot have properties, so what is "s1.length" ?
    Objects are passed by reference and primitive data types by value. But in this example you can see that an object s3 is passed by a value to function test().
    So what is the difference between s1, s2 and s3 ?
    Is this article outdated ?

  12. #12

  13. #13
    JavaScript Guru (Big Ego) Arielladog's Avatar
    Join Date
    Jul 1999
    Location
    SC, USA
    Posts
    390
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    cagrET,

    THe last link adios left gives a good explanation.

    Strings, as we know, are primitives. However, when we use them we usually want to have the .lenth property and all the String methods, so JavaScript promotes them to objects.

    JavaScript sometimes does such conversions. For example, if you put something like:

    if(new Object())

    It converts that into a boolean. In a similar way, JavaScript often promotes String's between strings and String objects.

    Hope that clarifies some...more detail could be gone into about it, and I think the last link does a decent job.

    aDog
    Last edited by Arielladog; May 19, 2004 at 21:06.

  14. #14
    Anonymous
    SitePoint Community Guest
    What a great article. I have been using this sort of approach with ActionScript and hadn't yet tried it with JS. Very helpful in getting started. Thanks.

  15. #15
    George
    SitePoint Community Guest
    if i have an array of objects, how do i sort it by member function ?

  16. #16
    SitePoint Wizard silver trophy
    Join Date
    May 2003
    Posts
    1,843
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ::: certified wild guess :::

  17. #17
    DoctorJ
    SitePoint Community Guest
    Nice one. You exposed enough parallels between JS and general OO concepts that I understood the JS Object concept easily.

    You may find that by emphasising the importance the "this" variable, you will provide greater benefit to JSers who haven't tackled OO before.

  18. #18
    Lindsay
    SitePoint Community Guest
    Thankyou very much, this short tutorial cleared up a lot of confusion I had re javascript objects and how to customise them.

  19. #19
    SitePoint Guru hgilbert's Avatar
    Join Date
    Dec 2004
    Location
    London
    Posts
    839
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    amazing.
    short / clear / concise / effective.
    this guy is a master.

  20. #20
    PIBM
    SitePoint Community Guest
    Just what I was searching for :)

  21. #21
    James
    SitePoint Community Guest
    Very nice. I've been looking for someone to explain this to me forever...

  22. #22
    vijay
    SitePoint Community Guest
    Amazing! Just what I wanted to know!

  23. #23
    SitePoint Addict
    Join Date
    Mar 2005
    Posts
    214
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Arielladog
    cagrET,

    THe last link adios left gives a good explanation.

    Strings, as we know, are primitives. However, when we use them we usually want to have the .lenth property and all the String methods, so JavaScript promotes them to objects.

    JavaScript sometimes does such conversions. For example, if you put something like:

    if(new Object())

    It converts that into a boolean. In a similar way, JavaScript often promotes String's between strings and String objects.

    Hope that clarifies some...more detail could be gone into about it, and I think the last link does a decent job.

    aDog
    There is the same kind of things in Java and strings are not considered primitives in Java so there is no reason to consider strings as primitives in Javascript also . But it's true that the discripancy of syntax allows for the confusion just take it as a commodity because strings are so commonly used the conceptors of Java and Javascript surely thought the advantage would outpass this syntaxic incoherence. Some people don't think so, for example some python programmers take this as one pretext to criticize Java and prone proudly for the coherence of their loved python language .

  24. #24
    Marcus
    SitePoint Community Guest
    Very good. Some widespread, lightweight techniques, such as javascript and html, are being employed a lot by non-professionals, in non-professional ways.Thus, it may be difficult to find good explanations (or, indeed, examples) of their use. This tutorial was an exception.

  25. #25
    rycerz1411
    SitePoint Community Guest
    Good Article, but this is in every javascript book on the market.


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
  •