Pulkit Singhal
Quiz von , erstellt am more than 1 year ago

Measure your understanding of Javascript Prototypes

207
1
0
Pulkit Singhal
Erstellt von Pulkit Singhal vor mehr als 9 Jahre
Schließen

Prototypes in Javascript

Frage 1 von 6

1

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?

Wähle eine der folgenden:

  • 3

  • null

  • undefined

  • 0

Erklärung

Frage 2 von 6

1

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?

Wähle eine der folgenden:

  • 4

  • 3

  • null

  • undefined

  • 0

Erklärung

Frage 3 von 6

1

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?

Wähle eine der folgenden:

  • 4

  • 3

  • null

  • undefined

  • 0

Erklärung

Frage 4 von 6

1

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?

Wähle eine der folgenden:

  • 4

  • 3

  • null

  • undefined

  • 0

Erklärung

Frage 5 von 6

1

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?

Wähle eine der folgenden:

  • fluffy.age;
    4

    scratchy.age;
    3

  • fluffy.age;
    4

    scratchy.age;
    4

  • fluffy.age;
    3

    scratchy.age;
    3

Erklärung

Frage 6 von 6

1

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?

Wähle eine der folgenden:

  • fluffy.age;
    4

    scratchy.age;
    3

  • fluffy.age;
    3

    scratchy.age;
    3

  • fluffy.age;
    4

    scratchy.age;
    4

Erklärung