Are you ready?
11 questions to solve
Instructions
- This quiz goes to full-screen once you press the Start button.
- At the end of the quiz, you are able to review all the questions that you answered wrong and see their explanations.
Which of the following is the literal way to create an object with a property
x
of value 10
?Object literals are denoted by the
{}
braces written directly. Refer to Creating Objects for more details.Suppose that
obj
is a pure JavaScript object. What will typeof obj
return?JavaScript returns
"object"
for typeof
applied to any object. Refer to Creating Objects for more info.Objects can contain objects as property values. True or false?
This is indeed true! Had it been false, we wouldn't have had all the object-oriented system and inheritance structure of JavaScript!
Call the method
greet
shown below.var obj = {
x: 10,
y: 20,
fx: {
greet: function() { alert("Hello World!"); }
}
}
greet
is a property of fx
which is further a property of obj
. Hence we need to write obj.fx.greet()
to call the greet()
method.A method of an object is simply a property with a function definition as its value. True or false?
Refer to JavaScript Objects for more info.
What is the constructor way to create an empty object?
The constructor way always utilises the keyword
new
. Hence the correct answer is choice (B).It has been told to you that
ele
is an array. What will ele.constructor
return?Refer to Object Constructors for more info.
In JavaScript, custom classes like those in PHP, Java, C++ can be emulated using what?
JavaScript can emulate class behavior by using constructor functions. Read Object Constructors for more info.
JavaScript is a pure class-based object-oriented programming (OOP) language. True or false? If false then give the right description.
JavaScript is a prototype-based OOP language whereby objects interact with each other in prototypal chains. For more info refer to Object Prototypes.
What are the two kinds of objects properties we can have in JavaScript?
Choices (B), (C) and (D), involve things that aren't related to object properties in JavaScript whatsoever. Hence choice (A) is correct.