Custom Objects in Javascript

@T-Bone

This question paper focuses on the "Custom Objects" of Javascript. These Multiple Choice Questions (mcq) should be practiced to improve the Javascript skills required for various interviews (campus interview, walk-in interview, company interview), placement, entrance exam and other competitive examinations.

This question paper focuses on the "Custom Objects" of Javascript. These Multiple Choice Questions (mcq) should be practiced to improve the Javascript skills required for various interviews (campus interview, walk-in interview, company interview), placement, entrance exam and other competitive examinations.

Questions

1. What will be the output of the below code? class Rect { constructor(h, w) { this.height = h; this.width = w; } get foo() { return this.foo(); } foo() { return this.height * this.width; } } const sq = new Rect(5, 20); console.log(sq.foo());

Mark the correct option

2. Choose the correct syntax in order to access property of the object created? function Ticket(from,to,pName){ this.from=from; this.to=to; this.pName= pName; } var ticket=new Ticket( "Udaipur","Pune","Raj" );

Mark the correct option

3. Identify the correct syntax to create a JavaScript object for Employee with property empid, empName? function Ticket(from,to,pName){ this.from=from; this.to=to; this.pName= pName; } var ticket=new Ticket( "Udaipur","Pune","Raj" );

Mark the correct option

4. Consider the below code: Choose the appropriate statement to be inserted at line 2, in order to create a JavaScript object named student? var json= '{ "sId":2001,"sName":"John" }'; //line 2 console.log(student.sId+" "+student.sName);

Mark the correct option

5. What will be the output of the following JavaScript code? var obj = new Fun(); obj.constructor === Fun

Mark the correct option

6. If X is the superclass and Y is the subclass, then subclass inheriting the superclass can be represented as _________

Mark the correct option

7. What will be the output of the following JavaScript code? const ob1 = { a: 5, b: 10, c: 15 }; const ob2 = Object.assign({c: 8, d: 3}, ob1); console.log(ob2.c, ob2.d);

Mark the correct option

8. What will be the output of the following JavaScript code? const pt1 = {}; const ob1 = Object.create(pt1); console.log( Object.getPrototypeOf(ob1) === pt1 );

Mark the correct option

9. A linkage of series of prototype objects is called as :

Mark the correct option

10. Which is an equivalent code to invoke a function m of class o that expects two arguments x and y?

Mark the correct option

Index of Questions