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
    300
    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,576
    Thanks
    58
    Thanked 649 Times in 644 Posts
    Defines an object, survey, with 3 properties; question, firstQuestionDisplayed and lastQuestionDisplayed. All these have falsely values.

  3. #3
    Master Coder Dormilich's Avatar
    Join Date
    Jan 2010
    Location
    Behind the Wall
    Posts
    5,104
    Thanks
    19
    Thanked 538 Times in 532 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,576
    Thanks
    58
    Thanked 649 Times in 644 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
  •