Multiple choice technology programming languages


function Book(id, name) {
    this.id = id;
    this.name = name;
}
var book = new Book("1001", "Head First JavaScript");
alert(book.id);

  1. 1001

  2. error

  3. Head First JavaScript

  4. id

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

The Book constructor function creates objects with id and name properties using 'this'. When called with 'new Book("1001", "Head First JavaScript")', it creates an object where book.id = "1001" and book.name = "Head First JavaScript". The alert(book.id) correctly outputs "1001". Option B (error) is wrong because this is valid constructor syntax.