this in Function Calls

Share this video with your friends

Send Tweet

In most cases, the value of a function's this argument is determined by how the function is called. This lesson explains what this refers to when we call plain function. Marius points out how functions behave differently in strict and non-strict mode. "use strict" mode defaults this to undefined and prevents us from assigning values to undefined. We must call functions as a constructor to assign their this value correctly.

lotfi harrabi
lotfi harrabi
~ 7 years ago

there's a typo in the transcript: "It doesn't matter whether are not the cause side is in strict mode. "

should be "It doesn't matter whether or not the call site is in strict mode."

Sosyo Plus Bilgi Bil. Tekn. Dan. Hiz. A.S. SULTAN SELİM MAHALLESİ LİBADİYE SOKAK No:3/1 KAĞITHANE/İSTANBUL
Sosyo Plus Bilgi Bil. Tekn. Dan. Hiz. A.S. SULTAN SELİM MAHALLESİ LİBADİYE SOKAK No:3/1 KAĞITHANE/İSTANBUL
~ 7 years ago

http://prntscr.com/izvmmd even i am not in the use strict mode, it is not assigning firstName and last Name to the global scope. Just adding this new keyword before Person object prevented defining variables to the global scope.