Prototypes in Javascript

Descripción

Measure your understanding of Javascript Prototypes
Pulkit Singhal
Test por Pulkit Singhal, actualizado hace más de 1 año
Pulkit Singhal
Creado por Pulkit Singhal hace más de 9 años
207
1

Resumen del Recurso

Pregunta 1

Pregunta
function Cat(name, color) { this.name = name; this.color = color; } Cat.prototype.age = 3; var fluffy = new Cat("Fluffy", "White"); var scratchy = new Cat("Scratchy", "Black"); What is the value for fluffy.age and scratch.age?
Respuesta
  • 3
  • null
  • undefined
  • 0

Pregunta 2

Pregunta
Given that a function’s prototype is just an object, then what would happen if we started changing the properties of a function’s prototype after we created objects from it? function Cat(name, color) { this.name = name; this.color = color; } Cat.prototype.age = 3; var fluffy = new Cat("Fluffy", "White"); var scratchy = new Cat("Scratchy", "Black"); Cat.prototype.age = 4; What is the value for fluffy.age and scratchy.age?
Respuesta
  • 4
  • 3
  • null
  • undefined
  • 0

Pregunta 3

Pregunta
function Cat(name, color) { this.name = name; this.color = color; } Cat.prototype.age = 3; var fluffy = new Cat("Fluffy", "White"); var scratchy = new Cat("Scratchy", "Black"); Cat.prototype = {age: 4}; What is fluffy.age and scratchy.age?
Respuesta
  • 4
  • 3
  • null
  • undefined
  • 0

Pregunta 4

Pregunta
function Cat(name, color) { this.name = name; this.color = color; } Cat.prototype.age = 3; var fluffy = new Cat("Fluffy", "White"); var scratchy = new Cat("Scratchy", "Black"); Cat.prototype = {age: 4}; var muffin = new Cat("Muffin", "Brown"); What is muffin.age?
Respuesta
  • 4
  • 3
  • null
  • undefined
  • 0

Pregunta 5

Pregunta
function Cat(name, color) { this.name = name; this.color = color; } Cat.prototype.age = 3; var fluffy = new Cat("Fluffy", "White"); var scratchy = new Cat("Scratchy", "Black"); fluffy.age = 4; What is fluffy.age and scratchy.age?
Respuesta
  • fluffy.age; 4 scratchy.age; 3
  • fluffy.age; 4 scratchy.age; 4
  • fluffy.age; 3 scratchy.age; 3

Pregunta 6

Pregunta
function Cat(name, color) { this.name = name; this.color = color; } Cat.prototype.age = 3; var fluffy = new Cat("Fluffy", "White"); var scratchy = new Cat("Scratchy", "Black"); fluffy.__proto__.age = 4; What is fluffy.age and scratchy.age?
Respuesta
  • fluffy.age; 4 scratchy.age; 3
  • fluffy.age; 3 scratchy.age; 3
  • fluffy.age; 4 scratchy.age; 4
Mostrar resumen completo Ocultar resumen completo

Similar

Quiz - Object Oriented Javascript
arunram.krish
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 DOM API - Funções Basicas - Interactive Web Pages
Victor Bini
Javascript Variables
Rene Escobar