Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Regular Coder
    Join Date
    May 2010
    Posts
    298
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Javascript Syntax Questions

    What this code do?
    PHP Code:
    survey = { questionsundefined,
               
    firstQuestionDisplayed: -1,
               
    lastQuestionDisplayed: -1}; 

  2. #2
    Senior Coder xelawho's Avatar
    Join Date
    Nov 2010
    Location
    Here
    Posts
    3,550
    Thanks
    57
    Thanked 645 Times in 640 Posts
    Defines an object, survey, with 3 properties; question, firstQuestionDisplayed and lastQuestionDisplayed. All these have falsely values.

  3. #3
    Senior Coder Dormilich's Avatar
    Join Date
    Jan 2010
    Location
    Behind the Wall
    Posts
    4,983
    Thanks
    19
    Thanked 532 Times in 526 Posts
    -1 is not a falsy value (that would be 0) ... although it can mean 'item not found' (cf. Array.indexOf(), String.indexOf())
    The computer is always right. The computer is always right. The computer is always right. Take it from someone who has programmed for over ten years: not once has the computational mechanism of the machine malfunctioned.
    André Behrens, NY Times Software Developer

  4. #4
    Senior Coder xelawho's Avatar
    Join Date
    Nov 2010
    Location
    Here
    Posts
    3,550
    Thanks
    57
    Thanked 645 Times in 640 Posts
    Oops. Right you are.


 

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •