Namespace for my JavaScript Library

Discussion in 'Javascript' started by petermichaux@gmail.com, Mar 19, 2006.

  1. Guest

    Hi,

    What is the "approved" way to (almost) ensure that my library classes
    and objects don't conflict with others that I might use?

    I could prepend a string fragment to the name of everything

    function Peter_MyClass(){
    // init Peter_MyClass objects
    }

    var peter_myObj = new Peter_MyClass();

    Or I could create an class that contains everything in my library. I'm
    not sure how this is done. Maybe like this?

    function Peter(){}

    Peter.MyClass = function(){
    // init MyClass objects
    };

    Peter.myObj = new Peter.MyClass();

    Any thoughts about these two methods or another suggestion greatly
    appreciated.

    Thank,
    Peter
    , Mar 19, 2006
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Èý¹â
    Replies:
    1
    Views:
    567
    William F. Robertson, Jr.
    Jul 29, 2003
  2. Replies:
    0
    Views:
    5,129
  3. Anonymous
    Replies:
    3
    Views:
    530
    Ron Natalie
    Aug 18, 2003
  4. Jason Heyes
    Replies:
    1
    Views:
    449
    Woebegone
    Nov 19, 2004
  5. Petter Reinholdtsen
    Replies:
    9
    Views:
    4,355
    Howard
    Nov 29, 2004
Loading...

Share This Page