Transcript from the "new & this Keywords" Lesson
>> Will: Introducing the keyword that automates all the hard work. The new keyword. We're gonna call, we're gonna run our function with a new keyword in front of it, inserted. And that people is going to automate. So we're gonna insert a new keyword in here. Folks, that's gonna automate three major things.
[00:00:25] It's gonna make our object for us. No declaring it using object.create, no no no no. It's gonna make it for us. We're not gonna have to return the object out ourselves, it's just gonna return it out automatically. The object it made. We're not, hm. So that's saving us some work.
[00:00:43] It's also creating some challenges. Now we need to adjust how we write the body of userCreator. For example, how can we refer to this auto created object, before the object we created was done manually by us? We referred to it, to add properties to it using newUser. We declared an object, newUser, and we referred to it as newUser.
>> Michael: Constructor.
>> Chris: This.
>> Will: Spot on Chris, the keyword this, exactly.
[00:01:25] But also there's another challenge. Whereas before, when we declared that object, we wanted that object not to require itself to have the functions like increment and login, but to have a link to them through what hidden property, David?
>> David: Proto.
>> Will: Through proto. But now we don't get to make that bond ourselves.
[00:01:48] That object's being made automatically and we wanna save ourselves making that bond. So where the hell are we gonna and, how are we gonna make that bond to a set of shared functions? And not only that, that set of shared functions, that Object of shared functions. How are we gonna make a bond to it?
[00:02:32] The all of the objects that get returned from running user creator with the help of this new keyword will automatically get a bond to this set of functions. But where can we put them do we need to maybe create an object called? I don't know like same name as a function user creator and then functions or something, I don't know.
[00:02:55] Where is it? How we're gonna do it? Now, we need to adjust how to write the body user creator, having regular grid object, no problem, keyword this. But how can we know where to put our single copies of the functions?