Understand the Constructor Property

I absolutely don’t understand the example code from this lesson.
Can some one please explain?

What is candidate.constructor ?

Your code so far

function Dog(name) {
  this.name = name;

// Add your code below this line
function joinDogFraternity(candidate) {
  if (candidate.constructor === Dog) {
    return true;
  } else {
    return false;

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.181 Safari/537.36.

Link to the challenge:

I’m having a hard time getting into the relevant challenge, but I’m guessing (easy enough given the code) that the ‘candidate’ is an object of some kind and ‘constructor’ is the constructor method of that object. So then, if I’m correct, ‘candidate.constructor’ is trying to figure out what type of object you’ve got. (eg. is it a type of Dog)

1 Like

Thanks. Now I get it.

1 Like