Defining Constants

Discussion in 'Javascript' started by Gene Wirchenko, Dec 15, 2011.

  1. Dear JavaScripters:

    I want to include some constants for use with my date type. This
    is related to my question about toString() parameters.

    Should I do

    1) Defined in Object

    function JustDate()
    {
    ....
    this.JDFmtISO8601=1;
    this.JDFmtIMA=2;
    ....

    or

    2) Defined Outside Object

    JDFmtISO8601=1;
    JDFmtIMA=2;

    function JustDate()
    {
    ....

    Does it really matter?

    Sincerely,

    Gene Wirchenko
    Gene Wirchenko, Dec 15, 2011
    #1
    1. Advertising

  2. In comp.lang.javascript message <c8nke7t4hcpkapltpsntad1d55k7le2q8u@4ax.
    com>, Thu, 15 Dec 2011 14:42:00, Gene Wirchenko <> posted:

    >
    >1) Defined in Object
    >
    > function JustDate()
    > {
    >...
    > this.JDFmtISO8601=1;
    > this.JDFmtIMA=2;
    >...


    Avoid "JD" in this context; it already has an established meaning in
    connection with dates.

    Consider also

    var GWC = { JDFmtISO8601 : 1 , JDFmtIMA : 2 , ... }

    --
    (c) John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v6.05 MIME.
    Web <http://www.merlyn.demon.co.uk/> - FAQish topics, acronyms, & links.
    Proper <= 4-line sig. separator as above, a line exactly "-- " (SonOfRFC1036)
    Do not Mail News to me. Before a reply, quote with ">" or "> " (SonOfRFC1036)
    Dr J R Stockton, Dec 16, 2011
    #2
    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. Guest
    Replies:
    1
    Views:
    648
    Sajan
    Feb 4, 2004
  2. Joe
    Replies:
    29
    Views:
    852
    Stewart Gordon
    Mar 4, 2004
  3. johny smith
    Replies:
    8
    Views:
    400
    Peter Koch Larsen
    Jul 2, 2004
  4. Sriram Chadalavada

    Defining/declaring constants in Python

    Sriram Chadalavada, Jul 28, 2003, in forum: Python
    Replies:
    2
    Views:
    4,166
    Michael Hudson
    Jul 29, 2003
  5. Thomas Sondergaard

    Defining constants in global scope

    Thomas Sondergaard, Sep 19, 2003, in forum: Ruby
    Replies:
    2
    Views:
    106
Loading...

Share This Page