Master the essential concepts of objects and object-oriented programming with these multiple-choice questions. This set covers object declaration, properties, the this keyword, and methods—ideal for JavaScript and OOP learners.
var obj = {name: "John"}var obj = "John";var obj() = {name: "John"};declare obj {name: "John"}console.log(obj.name); if obj = {name: "Alice"};?
undefinednullobj.nameobj["first name"]obj.first nameobj.first-nameobj{first name}obj[prop]obj.propobj{prop}prop(obj)+-.&console.log(person["age"]); display if var person = {age: 25};?
undefined25nullerrorobj["property"]["nested"]obj.property:nestedobj{property}.{nested}obj+property.nestedlet car = {color: "blue"};, which of the following accesses the color property?
car[color]car.colorcar{color}car.color[]object.property = value;object{property} = value;object->property = value;object(property) = value;delete person.age; if person = {age: 30};?
age = nullage property is removedage becomes undefinedcolor property of car to "red" if let car = {color: "blue"};?
car.color = "red";car("color") = "red";update car.color = "red";color = "red";remove()deleteclear()cut()car.model = "Sedan"; do if car initially has no model property?
model property to carundefinedmodel propertyconsole.log(obj.height); after delete obj.height;?
nullundefinederrorobj[variable] = value;obj(variable) = value;obj.variable(value);obj->variable = value;object.property = newValue;object->property = newValue;object.updateProperty = newValue;update.object.property(newValue);this Keyword Basicsthis refer to by default?
this keyword?
this used in a method?
this refers to the global objectthis refers to the calling objectthis is undefined in methodsthis refers to the nested objectthis.name represent inside an object method?
name property of the objectnamename property in global scopethis bound to in an arrow function?
this is always undefinedthis undefined in an object?
this in a nested function without bindingthis refer to when invoked outside any function or object?
nullthis to a specific object in JavaScript?
.bind(this).bind(object)object.this().apply(object, this)method: function() { /* code */ }function.method() { /* code */ }object.method() = function { /* code */ }method() => { /* code */ }greet in an object person?
person.greet()greet(person)person["greet"]call person.greet()return keyword used for in a method?
let obj = { add: function(x, y) { return x + y; }};, what does obj.add(2, 3); return?
523undefinedthis.propertyNameobj.propertyNamereturn.propertyNamepropertyName.this| Qno | Answer |
|---|---|
| 1 | A) var obj = {name: "John"}; |
| 2 | A) “Alice” |
| 3 | A) obj["first name"] |
| 4 | A) obj[prop] |
| 5 | C) . |
| 6 | B) 25 |
| 7 | A) obj["property"]["nested"] |
| 8 | B) car.color |
| 9 | A) object.property = value; |
| 10 | B) The age property is removed |
| 11 | A) car.color = "red"; |
| 12 | B) delete |
| 13 | A) Adds model property to car |
| 14 | C) undefined |
| 15 | A) obj[variable] = value; |
| 16 | A) object.property = newValue; |
| 17 | A) The object itself |
| 18 | B) A pointer to the calling context |
| 19 | B) this refers to the calling object |
| 20 | A) Accesses the name property of the object |
| 21 | B) Its lexical scope |
| 22 | B) Using strict mode with function expressions |
| 23 | A) Global object (e.g., window in browsers) |
| 24 | B) .bind(object) |
| 25 | A) method: function() { /* code */ } |
| 26 | B) Method |
| 27 | A) person.greet() |
| 28 | A) To end the function and send a value back |
| 29 | A) 5 |
| 30 | A) Use this.propertyName |