variables should be declared in examples in the FAQ

Discussion in 'Javascript' started by Nickolay Ponomarev, Jan 22, 2007.

  1. Assigning to undeclared variables is considered a bad practice (I hope
    I don't need to explain the reasons here). The examples in the FAQ
    should declare the variables it uses:

    http://www.jibbering.com/faq/#FAQ4_15
    > DocDom = (document.getElementById?true:false);


    http://www.jibbering.com/faq/#FAQ4_42
    > wRef = window.open("http://example.com/page.html","windowName");


    Nickolay
     
    Nickolay Ponomarev, Jan 22, 2007
    #1
    1. Advertising

  2. In comp.lang.javascript message <
    legroups.com>, Sun, 21 Jan 2007 17:37:24, Nickolay Ponomarev
    <> posted:
    >Assigning to undeclared variables is considered a bad practice (I hope
    >I don't need to explain the reasons here). The examples in the FAQ
    >should declare the variables it uses:
    >
    >http://www.jibbering.com/faq/#FAQ4_15
    >> DocDom = (document.getElementById?true:false);

    >
    >http://www.jibbering.com/faq/#FAQ4_42
    >> wRef = window.open("http://example.com/page.html","windowName");



    There is no need to show the declaration of variables unless the region
    within which they need to be declared is shown in full.

    --
    (c) John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Delphi 3? Turnpike 6.05
    <URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/&c., FAQqy topics & links;
    <URL:http://www.bancoems.com/CompLangPascalDelphiMisc-MiniFAQ.htm> clpdmFAQ;
    <URL:http://www.borland.com/newsgroups/guide.html> news:borland.* Guidelines
     
    Dr J R Stockton, Jan 22, 2007
    #2
    1. Advertising

  3. On Jan 22, 4:46 pm, Dr J R Stockton <>
    wrote:
    > In comp.lang.javascript message <
    > legroups.com>, Sun, 21 Jan 2007 17:37:24, Nickolay Ponomarev
    > <> posted:
    >
    > >Assigning to undeclared variables is considered a bad practice (I hope
    > >I don't need to explain the reasons here). The examples in the FAQ
    > >should declare the variables it uses:

    >
    > >http://www.jibbering.com/faq/#FAQ4_15
    > >> DocDom = (document.getElementById?true:false);

    >
    > >http://www.jibbering.com/faq/#FAQ4_42
    > >> wRef = window.open("http://example.com/page.html","windowName");

    > There is no need to show the declaration of variables unless the region
    > within which they need to be declared is shown in full.
    >

    It is shown in full, since you can copy paste these snippets to use in
    your code (I imagine this is the reason those snippets are in the FAQ).

    No need to write a several-pages-long witty response as to why they are
    not in fact shown in full - I'm not going to argue anymore.

    Nickolay
     
    Nickolay Ponomarev, Jan 23, 2007
    #3
  4. Nickolay  Ponomarev

    Lee Guest

    Nickolay Ponomarev said:
    >
    >On Jan 22, 4:46 pm, Dr J R Stockton <>
    >wrote:
    >> In comp.lang.javascript message <
    >> legroups.com>, Sun, 21 Jan 2007 17:37:24, Nickolay Ponomarev
    >> <> posted:
    >>
    >> >Assigning to undeclared variables is considered a bad practice (I hope
    >> >I don't need to explain the reasons here). The examples in the FAQ
    >> >should declare the variables it uses:

    >>
    >> >http://www.jibbering.com/faq/#FAQ4_15
    >> >> DocDom = (document.getElementById?true:false);

    >>
    >> >http://www.jibbering.com/faq/#FAQ4_42
    >> >> wRef = window.open("http://example.com/page.html","windowName");

    >> There is no need to show the declaration of variables unless the region
    >> within which they need to be declared is shown in full.
    >>

    >It is shown in full, since you can copy paste these snippets to use in
    >your code (I imagine this is the reason those snippets are in the FAQ).
    >
    >No need to write a several-pages-long witty response as to why they are
    >not in fact shown in full - I'm not going to argue anymore.


    What a jerk. "Don't bother pointing out that I'm wrong, I'm not
    going to respond".

    if(window.open){
    wRef = window.open("http://example.com/page.html","windowName");
    }

    Hardly qualifies as a snippet that would be copied and pasted.


    --
     
    Lee, Jan 23, 2007
    #4
  5. On Jan 23, 4:35 am, Lee <> wrote:
    > Nickolay Ponomarev said:
    >
    > >No need to write a several-pages-long witty response as to why they are
    > >not in fact shown in full - I'm not going to argue anymore.

    > What a jerk. "Don't bother pointing out that I'm wrong, I'm not
    > going to respond".
    >
    > if(window.open){
    > wRef = window.open("http://example.com/page.html","windowName");
    >
    > }Hardly qualifies as a snippet that would be copied and pasted.
    >

    At least you kept it short :)

    Nickolay
     
    Nickolay Ponomarev, Jan 23, 2007
    #5
  6. Nickolay Ponomarev wrote:
    > On Jan 23, 4:35 am, Lee <> wrote:
    > > if(window.open){
    > > wRef = window.open("http://example.com/page.html","windowName");
    > >
    > > }
    > > Hardly qualifies as a snippet that would be copied and pasted.
    > >


    BTW, that snippet is rather questionable. I wonder on what browsers
    that support scripting the window.open call doesn't happen.

    Nickolay
     
    Nickolay Ponomarev, Jan 23, 2007
    #6
  7. Nickolay Ponomarev wrote:
    > Nickolay Ponomarev wrote:
    >> On Jan 23, 4:35 am, Lee wrote:
    >>> if(window.open){
    >>> wRef = window.open("http://example.com/page.html","windowName");
    >>>
    >>> }
    >>> Hardly qualifies as a snippet that would be copied and pasted.


    Indeed the intention of the entry (and linked resources) is to
    discourage the attempt to open new windows.

    > BTW, that snippet is rather questionable. I wonder on what browsers
    > that support scripting the window.open call doesn't happen.


    Embedded browsers on small systems that have no "window" concept in
    their UI often do not provide a window.open method. There would be
    little point as they could not open new "windows" even if they wanted
    to. A specific example is WebBrowser 2.0 on the Palm OS (which is a
    ECMA 262, 3rd Ed. scriptable, W3C DOM (Core + HTML) Level 1 standard
    browser).

    Given that mobile phones are now at the point where it is becoming
    difficult to get one that does not have a web browser these small-scale
    and functionally restricted browsers are probably about to peek in
    their relevance.

    Richard.
     
    Richard Cornford, Jan 23, 2007
    #7
  8. On Jan 23, 1:52 pm, "Richard Cornford" <>
    wrote:
    > Nickolay Ponomarev wrote:
    > > Nickolay Ponomarev wrote:
    > >> On Jan 23, 4:35 am, Lee wrote:
    > >>> if(window.open){
    > >>> wRef = window.open("http://example.com/page.html","windowName");

    >
    > >>> }
    > >>>

    > Hardly qualifies as a snippet that would be copied and pasted.Indeed the intention of the entry (and linked resources) is to
    > discourage the attempt to open new windows.
    >
    > > BTW, that snippet is rather questionable. I wonder on what browsers
    > > that support scripting the window.open call doesn't happen.

    > Embedded browsers on small systems that have no "window" concept in
    > their UI often do not provide a window.open method. There would be
    > little point as they could not open new "windows" even if they wanted
    > to. A specific example is WebBrowser 2.0 on the Palm OS (which is a
    > ECMA 262, 3rd Ed. scriptable, W3C DOM (Core + HTML) Level 1 standard
    > browser).
    >

    Thanks for the information; didn't know there are embedded browsers
    with DOM support, but without window.open.

    By the way, I was looking at the first snippet (4.15) when I claimed it
    was on the page for easy copy-paste.

    Nickolay
     
    Nickolay Ponomarev, Jan 23, 2007
    #8
    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. Anand Sagar
    Replies:
    2
    Views:
    3,437
    Anand Sagar
    Jun 15, 2004
  2. JohnZing

    declared or not declared ?

    JohnZing, Feb 5, 2006, in forum: ASP .Net
    Replies:
    3
    Views:
    1,599
    Jon Paal
    Feb 5, 2006
  3. elzacho
    Replies:
    5
    Views:
    330
    Malcolm
    Sep 24, 2005
  4. Jeff
    Replies:
    2
    Views:
    102
  5. Garrett Smith

    Where Should Variables be Declared?

    Garrett Smith, Sep 16, 2009, in forum: Javascript
    Replies:
    2
    Views:
    180
    Matt Kruse
    Sep 16, 2009
Loading...

Share This Page