arunram.krish
Test por , creado hace más de 1 año

Quiz on Object Oriented Javascript

5844
3
0
arunram.krish
Creado por arunram.krish hace alrededor de 8 años
Cerrar

Quiz - Object Oriented Javascript

Pregunta 1 de 15

1

What are the different ways in which you can create a javascript object? Choose ALL the right options

Selecciona una o más de las siguientes respuestas posibles:

  • var object = { prop1: "value1", prop2 : "value2"};

  • var object = new Object();

  • var object = {};

  • var object = Object.create({});

Explicación

Pregunta 2 de 15

1

How to create a constructor function?

Selecciona una de las siguientes respuestas posibles:

  • Any function when prefixed with "new" keyword at the time of invocation acts like a constructor function.

  • Name of the function should be "constructor"

  • You have to assign a property named "constructor" and assign a function to it

  • Constructor function cannot be created in javascript

Explicación

Pregunta 3 de 15

1

How do you demonstrate inheritance in Javascript? Consider "BaseClass" is the name of the parent class and "SubClass" is the name of the sub-class.

Selecciona una de las siguientes respuestas posibles:

  • class SubClass extends BaseClass { }

  • function SubClass() {
    BaseClass.apply(this, Array.prototype.slice.call(arguments, 0);
    }
    SubClass.prototype = Object.create(BaseClass.prototype);

  • function SubClass() {
    BaseClass.apply(this, Array.prototype.slice.call(arguments, 0);
    }

  • function SubClass() {
    super(Array.prototype.slice.call(arguments, 0));
    }
    SubClass.prototype = Object.create(BaseClass.prototype);

Explicación

Pregunta 4 de 15

1

When does a Closure scope gets created?

Selecciona una de las siguientes respuestas posibles:

  • Every function has a Closure scope associated with it

  • Every time a inner function is defined within another function

  • When an inner function is defined within another function and that refers to variables that are available at the defining function (local variables of enclosing functions and its parent right until global)

  • A closure keyword is available. When a variable is declared with that modifier, closure scope is created

Explicación

Pregunta 5 de 15

1

How can I create a constant in Javascript 5?

Selecciona una de las siguientes respuestas posibles:

  • const myConstant = 3.414;

  • var myConstant = { value : "3.414";}

  • var myConstant = new Object(3.414)

  • var myConstant = Object.create(null, { value: {
    configurable : false,
    writable : false,
    enumerable : false,
    value : 3.414
    }
    });

Explicación

Pregunta 6 de 15

1

How does Javascript achieve Inheritance?

Selecciona una de las siguientes respuestas posibles:

  • Inheritance using extends keyword

  • Inheritance through Constructor chaining

  • Inheritance through Prototype chaining

  • Inheritance achieved programmatically

Explicación

Pregunta 7 de 15

1

Javascript does not support overriding?

Selecciona uno de los siguientes:

  • VERDADERO
  • FALSO

Explicación

Pregunta 8 de 15

1

It is a better practice (in terms of performance) to create deep inheritance and access methods in the ancestor classes.

Selecciona uno de los siguientes:

  • VERDADERO
  • FALSO

Explicación

Pregunta 9 de 15

1

It is possible to create namespaces in Javascript.

Selecciona uno de los siguientes:

  • VERDADERO
  • FALSO

Explicación

Pregunta 10 de 15

1

It is possible to implement Singleton pattern in javascript.

Selecciona uno de los siguientes:

  • VERDADERO
  • FALSO

Explicación

Pregunta 11 de 15

1

Every Javascript function is an object with the constructor as "Function"

Selecciona uno de los siguientes:

  • VERDADERO
  • FALSO

Explicación

Pregunta 12 de 15

1

How can I create immutable property in a javascript object?

Selecciona una de las siguientes respuestas posibles:

  • Using closure

  • Using JSON

  • Using Object.defineProperty and specify only get and no set function

  • By making the property private

Explicación

Pregunta 13 de 15

1

How to ensure that a property in Javscript object is never removed or re-configured

Selecciona una de las siguientes respuestas posibles:

  • Define the property with private modifier

  • It is not possible to stop removing the property from object

  • Every property defined using "Object.defineProperty" cannot be removed

  • Using Object.defineProperty and setting "configurable" to false

Explicación

Pregunta 14 de 15

1

How can I avoid creating global variables and functions used most often for initialization?

Selecciona una de las siguientes respuestas posibles:

  • Using temporary inner / anonymous function functions

  • Using just closure

  • Using constructor

  • Using window object

Explicación

Pregunta 15 de 15

1

How can I create Block - scoped variable in ES-6?

Selecciona una de las siguientes respuestas posibles:

  • Using var

  • Using let

  • Using const

  • Using def

Explicación