Multiple choice technology programming languages

What is the output of the below JavaScript?


    var currDate = new Date("30 September, 2011");
    alert(currDate.getMonth());

  1. 9

  2. 8

  3. 10

  4. error

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

JavaScript Date months are zero-indexed (January = 0, February = 1, etc.). September is the 9th month, so getMonth() returns 8. The code creates a Date object for September 30, 2011, and getMonth() correctly returns 8 for September. Option A (9) incorrectly assumes 1-based indexing.