What I Learned Yesterday - "This" is confusing
Every day at AcademicWorks, the Engineering Team has a Dev Sync where we share something we learned from the day before. Often times we’ll hear about some new movie, a cool Kickstarter project, or an interesting ruby gem. Our VP of Engineering has issued a challenge to our team: Whoever can teach something they learned from the day before that is 1) technical in nature and 2) directly related to our work for 20 consecutive days will win a prize. Here is what I learned yesterday…
this is confusing
It can be used in:
- outside functions (in the top-level scope)
- in a string passed to
What I learned
this, strict mode assigns
undefined instead of the global object (
window in the browser).
- If you forget the keyword
newwhen invoking a constructor function,
thiscould be assigned to the global object if you were in “sloppy mode”.