SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Hybrid View

  1. #1
    SitePoint Guru afridy's Avatar
    Join Date
    Mar 2007
    Posts
    971
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Variable Declaration issue

    Hai all,

    i am new to JS.

    i did not undestand weather 'var' Keyword should be used or not when declaring variables. i already familier with php and there i will not use a 'var' for variable declaration. i like to program JS using similler PHP sysntax. so i code JS with out 'var' for varialb declarations and it works.

    but can you please tell is it ok to declare variables with out the key word 'var'? if this is not good, then do all global and local variable declarations requir 'var'?

  2. #2
    SitePoint Addict darkwater23's Avatar
    Join Date
    Nov 2005
    Location
    Omaha, NE
    Posts
    335
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    var is good to use. It useful at managing the scope of a variable. Here's a tiny explanation. I'm sure there's better ones out there, but this was fast.

    http://www.webmonkey.com/98/29/index0a_page5.html

  3. #3
    SitePoint Guru afridy's Avatar
    Join Date
    Mar 2007
    Posts
    971
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by darkwater23 View Post
    var is good to use. It useful at managing the scope of a variable. Here's a tiny explanation. I'm sure there's better ones out there, but this was fast.

    http://www.webmonkey.com/98/29/index0a_page5.html
    Thanks darkwater,

    so it is recommend to use var every time declaring a variable regardless of Global or Local.


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
  •