the first way to call a function is as a method.
So when we call a method, the this keyword inside that method will simply point to the object on
which the method is called,or in other words, it points to the object that is calling the method.



Why is the disk keyword undefined in this function, but window in this
function? Well, it is because the arrow function does not get its own this keyword. So instead the arrow function simply uses the lexical this keyword, which means that it uses the disc keyword of its parent function or of its parents scope.

And so here we are calling the method on Matilda right? And so therefore the this keyword will point to Matilda, which was the object, which called the method.
So even though the method is written here inside of the Jonas object the this keyword will still point to Matilda.

var firstName= 'Matilda' 지우면 Hey undefined가됨. var를 쓰지 말아야하는 이유

-> by just using a regular function. Right?
If we had this, then of course now this object Jonas, which is calling the functionㅠwould then be the this keyword. Right?
So you see first name Jonas, and then Hey Jonas.Because now this method actually does get its own this keyword.

why this undefined ?
IsMillenial(); is really just a regular function call, isn't it?
It is a regular function call, even though it happens inside of a method.**
And the rule says that inside a regular function call, which this clearly is, that this keyword must be undefined. And so therefore it is undefined right here.**
So this is just as if this function was outside of this method.
So if we copy this function out here, we would get the exact same result.
const isMillenial = function() {~~
밖에다 옮겨도 똑같은 결과 뜬다.

-> _So self is referenced here,but it's not of course in the scope.
And so JavaScript goes up the scope chain,into the parent scope, which is calcAge. So here is where self is defined, and it is defined as this.
So as to this keyword.And so this is a way in which we can preserve the this keyword. This can also be called that, so that you might also see._
And that solution is to use an arrow function. Alright.

-> And again, this worked because this arrow function uses the this keyword from its parent scope. And in this case, in the parent scope,the this keyword is Jonas.

So we would say that the age variable is equal to 30, but in fact, age is equal to the memory address 0001,


And the reason for this, as we can see in this slide is the fact that Me and Friend actually point to the exact same object in the memory heap.
So whenever we change something in this object, it will always be reflected in Friend and in Me.
So these are basically just two different identifiers pointing to the exact same value.
And once again, that value is the memory address D30F which points to the reference in the memory heap.
And one important implication of this is that whenever you think that you're copying an object,
you're really just creating a new variable that points to the exact same object.

new object was in fact created in the heap and JessicaCopy is now pointing to that object.
So, it has a reference to that new object.
However, there is still a problem because using this technique of object.assign only works on the first level.
Or in other words, if we have an object inside the object, then this inner object will actually still be the same.
So, it will still point to the same place in memory.
And that's why we say that this object.assign only creates a shallow copy
and not a deep clone which is what we would like to have.
So, again, a shallow copy will only copy the properties in the first level while a deep clone would copy everything.