N
N
N0op1ck2018-03-28 00:15:03
JavaScript
N0op1ck, 2018-03-28 00:15:03

What is it called?

I solve elementary (not for me) problems on codewars, and I didn’t understand the moment:

function Sleigh() {
  this.name = "Santa Claus";
  this.password = "Ho Ho Ho!";
}

Sleigh.prototype.authenticate = function(name, password) {
  return this.name == name && this.password == password;
};

What is Sleigh. prototype.authenticate and why this
ps construct in the task needs to return true if both match, and false if they don't match

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
Arman, 2018-03-28
@N0op1ck

Seems like one of the OOP options for JS =)
prototype says that all instances of the class *** will have such a property / method

S
Stalker_RED, 2018-03-28
@Stalker_RED

function Охранник() {
  this.name = "Штирлиц";
  this.password = "У вас продается славянский шкаф?";
}

Охранник.prototype.проверяй = function(name, password) {
  return this.name == name && this.password == password;
};

let Василий = new Охранник()
Василий.проверяй('Штирлиц', 'У вас продается славянский шкаф?')

PS: maybe you should buy a dictionary?

M
McBernar, 2018-03-28
@McBernar

All objects created by the Sleight constructor will have an authenticate method (function).
Here is such a strange JS-OOP. By the way, normal syntactic sugar is added to es6 to forget about prototype inheritance.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question