Object Literal Syntax
Which of the following is the correct way to define an object literal representing a car with properties 'make' and 'model'?
- let car = { make: 'Toyota', model: 'Camry' };
- let car = ( make: 'Toyota', model: 'Camry' );
- let car = object(make: 'Toyota', model: 'Camry');
- let car = [ make: 'Toyota', model: 'Camry' ];
- let car = { make = 'Toyota', model = 'Camry' };
Accessing Object Properties
Given the object let person = { name: 'Anna', age: 22 }, how can you access the value of 'age'?
- person(age)
- person::age
- person.age
- person-u003Eage
- person['ages']
Adding Object Properties
How can you add a property 'city' with the value 'London' to an existing object called user?
- user-u003Ecity('London');
- user.city = 'London';
- user[city] = 'London';
- user.add('city', 'London');
- user.city=('London');
Method Definition in Objects
What is the correct way to define a method called greet inside an object?
- greet() =u003E { console.log('Hello'); }
- greet[] = function() { console.log('Hello'); }
- function greet() { console.log('Hello'); }
- greet: function() { console.log('Hello'); }
- greet = function() { console.log('Hello'); }
The 'this' Keyword Context
In an object method, what does the 'this' keyword refer to?
- The function's prototype
- The parent object
- The current object calling the method
- An undefined context
- The global window object
Prototypal Inheritance
What does prototypal inheritance in JavaScript allow an object to do?
- Create private variables
- Restrict access to methods
- Inherit properties and methods from another object
- Compile code at runtime
- Force strict typing
Array map() Method
If you use the map() method on an array [1, 2, 3] with a function that multiplies each value by 2, what is the resulting array?
- [3, 2, 1]
- [2, 2, 2]
- [1, 2, 3, 6]
- [1, 4, 9]
- [2, 4, 6]
Array filter() Method
What will [5, 8, 12, 3].filter(x =u003E x u003E 6) return?
- [5, 8]
- [12, 3]
- [5, 8, 12]
- [3, 5, 8, 12]
- [8, 12]
Using Array reduce()
What does the array method reduce() typically output when called on [1, 2, 3] with (acc, val) =u003E acc + val as the callback?
- [2, 4, 6]
- 123
- 6
- [1, 2, 3]
- 1, 2, 3
Array forEach() Method
Which statement correctly describes what forEach() does to an array?
- It calls a provided function once for each array element
- It reduces the array to a single value
- It filters the array based on a condition
- It creates a new array by applying a function
- It sorts the array in place
Array find() Method
Given let arr = [10, 25, 30]; what does arr.find(x =u003E x u003E 20) return?
- [25, 30]
- undefined
- 10
- 25
- 30
Object Property Accessors
Which syntax correctly accesses a property with a key stored in the variable 'prop' from an object 'obj'?
- obj[prop()]
- obj.prop
- obj[prop]
- obj#prop
- obj-u003Eprop
Destructuring Arrays
How do you use array destructuring to extract the first two values from [7, 8, 9] into variables a and b?
- let (a, b) = [7, 8];
- let [a, b] = [7, 8, 9];
- let {a, b} = [7, 8, 9];
- let [a b] = [7, 8];
- let a, b = [7, 8];
Destructuring Objects
Given const person = { name: 'Kai', age: 30 }, what is the correct way to extract the name property into a variable?
- const [name] = person;
- const name = person['names'];
- const name = { person };
- const { name } = person;
- const name = person-u003Ename;
Checking Property Existence
What is the recommended way to check if an object obj has its own property 'id'?
- obj.exists('id')
- obj.contains('id')
- obj.idExist()
- obj.hasOwnProperty('id')
- hasProperty(obj, 'id')
Extending Object Prototypes
Which statement correctly adds a method speak() to the prototype of a constructor function Animal?
- Animal.prototype.speak = function() { console.log('Hi'); };
- Animal-u003Eprototype.speak = function() { console.log('Hi'); };
- Animal::speak = function() { console.log('Hi'); };
- Animal.prototype:speak = function() { console.log('Hi'); };
- Animal.speak = function() { console.log('Hi'); };