---
title: "Discussion on \"JavaScript: this is easy and what do you need to know about it!\" | Hashnode"
description: "Discussion on \"JavaScript: this is easy and what do you need to know about it!\". Introduction\nLet me start this article by thanking the readers of my series,  JavaScript: Cracking the Nuts for liking and loving it so far. This article will go through another fundamental but equally misunderstood aspect of JavaScript called the th..."
url: "https://hashnode.com/posts/javascript-this-is-easy-and-what-do-you-need-to-know-about-it/5f02b234b0b5c3083fffabac"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [JavaScript: this is easy and what do you need to know about it!](https://blog.greenroots.info/javascript-this-is-easy-and-what-do-you-need-to-know-about-it?utm_source=hashnode&utm_medium=feed)

Introduction Let me start this article by thanking the readers of my series, JavaScript: Cracking the Nuts for liking and loving it so far. This article will go through another fundamental but equally misunderstood aspect of JavaScript called the th...

Jul 6, 2020 · 10 min read · blog.greenroots.info  
Updated Dec 8, 2021  
Read the article

-   [#javascript](https://hashnode.com/tag/javascript)
-   [#beginners](https://hashnode.com/tag/beginners)
-   [#web-development](https://hashnode.com/tag/web-development)
-   [#programming](https://hashnode.com/tag/programming)
-   [#nodejs](https://hashnode.com/tag/nodejs)

## Written by

[Tapas Adhikary](https://hashnode.com/@atapas)

@atapas · Bangalore

  
[View profile](https://hashnode.com/@atapas)

Educator @tapaScript | Founder CreoWis & ReactPlay - Writer - YouTuber - Open Source

Co-Founder, @CreoWis | Teacher, @tapaScript | Founder, @ReactPlay | YouTuber | Writer | Human

## Responses 6

Markdown supported · ⌘↵ to post

[Uday Tewary](https://hashnode.com/@Itachi01)

[Nov 5, 2024](https://hashnode.com/posts/javascript-this-is-easy-and-what-do-you-need-to-know-about-it/5f02b234b0b5c3083fffabac/comment/6729c3a6469bacdb1d1dd3b3)

Really beautiful and amazing explanation [Tapas Adhikary](https://hashnode.com/@atapas) sir I recently got to know about U when I read ur blog on Promise and it was truly amazing loved ur explanation and it clear very much confusion of mine

[Juan](https://hashnode.com/@juan491)

[Apr 7, 2024](https://hashnode.com/posts/javascript-this-is-easy-and-what-do-you-need-to-know-about-it/5f02b234b0b5c3083fffabac/comment/66122211ab26ee37bda55d68)

Hello, I'm learning Javascript from internet and searching answers for knowing how 'this' works in arrow and normal functions get your amazing posts. It all was fine until I get the following part : "What do you think, this would be bound to here inside forEach? It is not an arrow function. It is a regular function, and it has its own execution context. In that execution context, there is nothing called a name. Hence this.name is undefined." Because of in your previous post about binding, the object on which the function is called define the binding of 'this'. So I don't understand which is the Object on which the anonymous function (inside of forEach) is called in this case. It would be good identify that in order to follow the thread of the previous explanations. I am aware of this is 4 year old, and maybe you are in other business, but I get here today and write this question just in any case. Thanks.

[Juan](https://hashnode.com/@juan491)

[Apr 7, 2024](https://hashnode.com/posts/javascript-this-is-easy-and-what-do-you-need-to-know-about-it/5f02b234b0b5c3083fffabac/comment/66122211ab26ee37bda55d68#reply-6612d030c32a88e015356bbf)

Well, I was doing more things to get clarify the 'this' unclear, in the example code from your post:

////////////////////////////////////////////////////

var testHobbies = { hobbies: \['Cricket', 'Football', 'Blogging'\], name: 'Alex', logHobbies() { this.hobbies.forEach(function(elem){ console.log(`${this.name} knows ${elem}`); }); } } ////////////////////////////////////////////////////////

So, changing in the code 'this.name' by only 'this' when it runs result the following output;

\[object global\] knows Cricket \[object global\] knows Football \[object global\] knows Blogging

Then taking from your explanation on the Binging part: "if the this keyword is not resolved with any of the above bindings, implicit, explicit or new then, the this binds to the window(global) object."

So in the example code above, the 'this' inside the anonymous function binds to object global, because 'this' keyword is not resolved with any of bindings: implicit, explict or new, and also it doesn't exist in its function context. That is what I understand until here.

[vamsee krishna](https://hashnode.com/@vamsikrishna4)

[Jun 11, 2022](https://hashnode.com/posts/javascript-this-is-easy-and-what-do-you-need-to-know-about-it/5f02b234b0b5c3083fffabac/comment/62a48aec165482d2b3eeb95d)

Awesome explanation throughout the series.

[Prateek Aher](https://hashnode.com/@prateek_aher)

[Aug 23, 2020](https://hashnode.com/posts/javascript-this-is-easy-and-what-do-you-need-to-know-about-it/5f02b234b0b5c3083fffabac/comment/5f42b38fb9aefd741aeaf666)

Loved your explanation Tapas.

[Prateek Aher](https://hashnode.com/@prateek_aher)

[Aug 23, 2020](https://hashnode.com/posts/javascript-this-is-easy-and-what-do-you-need-to-know-about-it/5f02b234b0b5c3083fffabac/comment/5f42990b82f012743b26a3ce)

In your code snippet under '**apply() method**', shouldn't `hobby1` and `hobby2` be replaced by `hobbies[0]` and `hobbies[1]` respectively?

[Tapas Adhikary](https://hashnode.com/@atapas)

[Aug 23, 2020](https://hashnode.com/posts/javascript-this-is-easy-and-what-do-you-need-to-know-about-it/5f02b234b0b5c3083fffabac/comment/5f42990b82f012743b26a3ce#reply-5f429e7f82f012743b26a3ea)

[Prateek Aher](https://hashnode.com/@prateek_aher),

Thanks for reading and commenting.

> shouldn't hobby1 and hobby2 be replaced by hobbies\[0\] and hobbies\[1\] respectively?

No, actually. The `apply` method is one step better than the `call` where you can pass the entire array as an argument. The number of parameters passed to the applied function would be mapped to the number of array elements passed to `apply` in the same order.

![image.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1598200754669/rN67lxyeR.png)

Another way to visualize it, think about the `arguments` itself. It is available to the function as local variable. See how I can retrieve with the element by element in this case.

```

var getName = function() {
     console.log(this.name + ' likes ' + arguments[0] + ' , ' + arguments[1]);
 }
 var user = {
   name: 'Tapas',
   address: 'Bangalore'  
 };

 var hobbies = ['Swimming', 'Blogging'];
 getName.apply(user, hobbies);
```

Hope I was able to clarify. Please let me know.

[Prateek Aher](https://hashnode.com/@prateek_aher)

[Aug 23, 2020](https://hashnode.com/posts/javascript-this-is-easy-and-what-do-you-need-to-know-about-it/5f02b234b0b5c3083fffabac/comment/5f42990b82f012743b26a3ce#reply-5f42b521b9aefd741aeaf674)

[Tapas Adhikary](https://hashnode.com/@atapas) It is clear to me now. My bad, I mistook the argument-list as parameters.

[John Philip](https://hashnode.com/@amjohnphilip)

[Jul 6, 2020](https://hashnode.com/posts/javascript-this-is-easy-and-what-do-you-need-to-know-about-it/5f02b234b0b5c3083fffabac/comment/5f0315edce3d41181dc272e1)

Good explanation

[Tapas Adhikary](https://hashnode.com/@atapas)

[Jul 6, 2020](https://hashnode.com/posts/javascript-this-is-easy-and-what-do-you-need-to-know-about-it/5f02b234b0b5c3083fffabac/comment/5f0315edce3d41181dc272e1#reply-5f0319cee3282319dc9e8260)

Thanks [John Philip](https://hashnode.com/@amjohnphilip)!
