Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

General Discussion Understanding "this" in JavaScript

tal Shnitzer
PLUS
tal Shnitzer
Courses Plus Student 5,242 Points

is it just me? I can't understand a word this guy is saying...

what does it mean that window is "global context"? really, it is frustrating

7 Answers

Steven Parker
Steven Parker
231,186 Points

He's explaining how the term "this" represents different things based on how it is used (and where in the code). The conditions related to where it is used are called the "context".

In that particular example, "this" is a reference to the window object. But as you proceed further in the video, you'll discover that in other situations it will have a different value.

Pitrov Secondary
Pitrov Secondary
5,121 Points

I cant understand it either, he does things that I've never seen before, for example 9:44 at line 2 3 how does || work there?

Steven Parker
Steven Parker
231,186 Points

That's a way of establishing default values. When you use the logical OR operator with strings, the value of the expression will be the same as the first term if it is determined to be "truthy" (not undefined or empty), but it will be the value of the second term otherwise.

Pitrov Secondary
Pitrov Secondary
5,121 Points

Have we learned about it in the full javascript course? I have never heard of some things that he talks about, or I cant remember learning about it?

Steven Parker
Steven Parker
231,186 Points

I doubt there's anything in a workshop that hasn't been introduced in a course, but it may draw from techniques shown in several different courses. It's also possible that the way techniques are applied is a bit different from the examples used in the course.

You might try asking the Support folks to add course references in the Teacher's Notes for specific things you were surprised by (such as the use of the "OR" operator with strings).

Pitrov Secondary
Pitrov Secondary
5,121 Points

How do I work in the console and why does he start with "node" when he types something in the console?

Steven Parker
Steven Parker
231,186 Points

The JavaScript engine being used is called "node".

You might enjoy and benefit from the Node.js Basics and Console Foundations courses.

Basil A
Basil A
2,009 Points

The instructor is obviously very good and knows his stuff but I also found this workshop to be a bit confusing and obfuscated.

When coding along with the examples none of the objectMethods.js snippets worked in VS Code, however they did work in the Workspace. Is this the same for you and others?

Thanks

Alex Franklin
Alex Franklin
12,403 Points

It was not a great idea to suddenly put everything in the environment of node without ever covering anything about it up to this point in the entire full stack track... So should I leave the full stack JavaScript track and go learn node.js? like why wouldn't that just be a part of this track before we jump into it without warning and those in the full stack track are completely lost when they arrive here...