Instructor: 00:00 Here is our sayHi function from the previous lesson again. How would we call sayHi with person as a receiver without a touching sayHi to person first? We can do this using the call method. Call is defined on the function prototype, and therefore available on every function.
00:23 As we can see this within this sayHi method, refers to the value we provide it explicitly we have the first argument. This argument is often called this arg. Alternatively, we can use the apply method which is also defined on the function prototype.
00:46 What's the difference between call and apply? In addition to the this arg, we can also specify arguments that we want to pass to the function. Call and apply accept this arguments in a slightly different way. Usually, when we invoke a method, we say object.methodname followed by the arguments in parentheses, where however is only syntactic sugar for the following call.
01:16 The first argument is the this arg and all arguments after that are the arguments that we want to pass to the function. We simply list them separated by comma. Instead of using call, we could've also use apply.
01:34 Again, the first argument is the this arg. Now, the second argument is an array like object that contains all the arguments that we want to pass to the function. In the end, all of the above select the same slice from the array.
01:56 Here is a simple pneumonic that helps me remember how call and apply expect their arguments. Call starts with the C, and therefore once a comma separated list. Apply starts with an A, and therefore once in array. It's a little cringe worthy, I know, but it sticks.
02:38 In strict mode, that doesn't happen. I recommend you write all of your code in strict mode, so your void surprises like these.