29 Questions
In JavaScript, when does it make sense to use object composition?
When one object has a type of another object
What would be the result of calling arr.unshift('Grace') after initializing the NumberArray object?
It would throw a TypeError because the method isn't defined
What does data hiding refer to in terms of object composition?
Keeping data inaccessible from outside the object
Which term is synonymous with object composition?
Encapsulation
What does it mean when one object has a type of another object in terms of object composition?
One object can be treated as an instance of another object
Why would a subclass restrict access to features of the superclass in object composition?
To prevent misuse or unintended modifications by the subclass
What is the main benefit of using inheritance in object-oriented programming?
Reduce complexity and redundancy by promoting code reuse
Which syntax is used for a concise method declaration in JavaScript?
Shorthand method syntax
In the context of classes in JavaScript, what does the 'super' keyword refer to?
A method to access the parent class' constructor
What action does the lib_trips.js file take if the miles and gallons values in the Trip class are not valid?
Returns false
What benefit does using JavaScript libraries provide?
Eases code understanding and reusability
Which operator is used to delete a property from an object in JavaScript?
delete operator
In the provided code snippet, what does 'emp instanceof Person' evaluate to?
True
What happens if a non-number value is pushed into a 'NumberArray' object?
A runtime error is thrown
What does the 'instanceof' operator do in JavaScript?
Checks if an object is an instance of a specific class
Which term refers to a class that inherits properties and methods from another class?
Subclass
In the context of JavaScript, what is meant by 'reference to an object'?
Pointing to the memory location of an object
Which aspect of code organization is encouraged by JavaScript libraries?
Separation of concerns
What is the purpose of the constructor
in the Invoice class?
To store and initialize the subtotal and tax rate
What type of property in JavaScript can only be read but not written to?
Read-only property
How many arguments are passed to the constructor when creating invoice2
?
Two
Which jQuery method is used to empty the HTML content of an element with the id 'tasks'?
$('#tasks').empty()
What does the class Trip represent in the Trips app?
A data structure for storing trip information
Which method is responsible for clearing the task list in the Trip class?
taskList.clear()
In the context of the Invoice class, what does the statement const invoice = new Invoice(100, 0.0875);
achieve?
Creates a new invoice object with a subtotal of 100 and a tax rate of 0.0875
What does the 'isValid' property in the Trip class indicate?
The miles and gallons values are valid
What is the primary role of the fullName
method in the Person class?
To return the combined first name and last name as a single string
When creating a new Person object, what parameters are required in the constructor?
First name and last name
What does the statement console.log(p instanceof Object);
verify about object p
?
p
is an instance of an Object class
Learn how to create a class Employee that inherits another class Person in JavaScript, along with creating and using an Employee object with specific properties. Explore the concept of inheritance and object creation in JavaScript.
Make Your Own Quizzes and Flashcards
Convert your notes into interactive study material.
Get started for free