Quiz - Object Oriented Javascript

Descrição

Quiz on Object Oriented Javascript
arunram.krish
Quiz por arunram.krish, atualizado more than 1 year ago
arunram.krish
Criado por arunram.krish mais de 8 anos atrás
5890
3

Resumo de Recurso

Questão 1

Questão
What are the different ways in which you can create a javascript object? Choose ALL the right options
Responda
  • var object = { prop1: "value1", prop2 : "value2"};
  • var object = new Object();
  • var object = {};
  • var object = Object.create({});

Questão 2

Questão
How to create a constructor function?
Responda
  • 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

Questão 3

Questão
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.
Responda
  • 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);

Questão 4

Questão
When does a Closure scope gets created?
Responda
  • 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

Questão 5

Questão
How can I create a constant in Javascript 5?
Responda
  • 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 } });

Questão 6

Questão
How does Javascript achieve Inheritance?
Responda
  • Inheritance using extends keyword
  • Inheritance through Constructor chaining
  • Inheritance through Prototype chaining
  • Inheritance achieved programmatically

Questão 7

Questão
Javascript does not support overriding?
Responda
  • True
  • False

Questão 8

Questão
It is a better practice (in terms of performance) to create deep inheritance and access methods in the ancestor classes.
Responda
  • True
  • False

Questão 9

Questão
It is possible to create namespaces in Javascript.
Responda
  • True
  • False

Questão 10

Questão
It is possible to implement Singleton pattern in javascript.
Responda
  • True
  • False

Questão 11

Questão
Every Javascript function is an object with the constructor as "Function"
Responda
  • True
  • False

Questão 12

Questão
How can I create immutable property in a javascript object?
Responda
  • Using closure
  • Using JSON
  • Using Object.defineProperty and specify only get and no set function
  • By making the property private

Questão 13

Questão
How to ensure that a property in Javscript object is never removed or re-configured
Responda
  • 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

Questão 14

Questão
How can I avoid creating global variables and functions used most often for initialization?
Responda
  • Using temporary inner / anonymous function functions
  • Using just closure
  • Using constructor
  • Using window object

Questão 15

Questão
How can I create Block - scoped variable in ES-6?
Responda
  • Using var
  • Using let
  • Using const
  • Using def

Semelhante

Examen Fundamentos Basicos de Programación
Jose Valderrama0721
Test I. Introduction to web technologies
Angel Martínez Rodriguez
JavaScript Fundamentals
Andrew Watters
Front-End Web Development
Chanthy Ngin
Javascript - Quiz - Jan 2016
arunram.krish
OpenSource Programming
Faheem Ahmed
Javascript basics
James Drummond
jQuery Basics functions and method
Victor Bini
Javascript Variables
Rene Escobar
JavaScript DOM API - Funções Basicas - Interactive Web Pages
Victor Bini
Programming
Herbert Fortes