Make a Person: where is the var and why its not in the Object.length

Tell us what’s happening:
I solved the challenge after looking at the solution (tbh). I understand the solution vaguely.

But what i not understand is, where is the var fullName or a:“Test” ? when i create the Person “Bob Ross”. Because after the creation i need access to var fullName otherwise would for example the command bob.getLastName() not work. But it works.

Also the var fullName is not in the Object.keys.length? Why?

I saw a video a few weeks ago, where the tutor talked about the “backpack” of a Object. So everytime we create an object the “surrounded” execution context will be stored in a backpack(which is “invisible”). Is this the case? So we create the object bob and then var fullName will be stored in the backpack of bob and now i can access to it and even can change it?

I hope you understand my question and why i am a bit confused.

  **Your code so far**

const Person = function(firstAndLast) {
// Only change code below this line
// Complete the method below and implement the others similarly
var fullName = firstAndLast;
a: "Test";

this.getFullName = function() {
  return fullName;
};

this.getFirstName = function() {
  return fullName.slice(0, fullName.indexOf(" "));
}
this.getLastName = function() {
  return fullName.slice(fullName.indexOf(" ")+1)
}

this.setFirstName = function(First) {
  fullName = fullName.replace(fullName.slice(0, fullName.indexOf(" ")), First);
}
this.setLastName = function(Last) {
  fullName = fullName.replace(fullName.slice(fullName.indexOf(" ")+1), Last)
}

this.setFullName = function(firstAndLast) {
  fullName = firstAndLast;
}


};

const bob = new Person('Bob Ross');

console.log(Object.keys(bob).length);
console.log(bob)
  **Your browser information:**

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:95.0) Gecko/20100101 Firefox/95.0

Challenge: Make a Person

Link to the challenge:

But what i not understand is, where is the var fullName or a:“Test”

They are “in” the object but are not directly accessible from the instance. They are “private” and can only be accessed inside the object constructor and its methods. (if I understand correctly)

I don’t know what a:“Test” is doing. If you wanted to make that a non-private object property, you could have done:

this.a = "Test";

Because after the creation i need access to var fullName otherwise would for example the command bob.getLastName() not work. But it works.

No, you don’t need to access it, the method does. And the method can.

Also the var fullName is not in the Object.keys.length? Why?

According to the docs:

The Object.keys() method returns an array of a given object’s own enumerable property names , iterated in the same order that a normal loop would.

And fullName is not an enumerable property of that object. It is not even a property. It is a variable in the object constructor that is referenced in the methods.

I’m sorry, but I’m not sure about your “backpack” metaphor. But suffice it to say that there are a lot of things contained in an object (and therefore any reference type) that is “invisible” in normal usage.