This content originally appeared on DEV Community and was authored by Chetan Atrawalkar?CA.
If you are working with javascript for a while, you will agree with me. This ‘this’
keyword is very confusing when you are writing code, especially when you read others code.
This may be controversial, but for me it's the this
keyword.
➡️ this
has a different values depending on where it is used.
➡️ Inside a method this
refers to the owner object.
➡️ When alone this
refers to the global object.
➡️ Inside a function this
this refers to the global object too.
➡️ In a function, in strict mode this
is undefined.
➡️ In a event this
refers to the element that received the event.
However, since 2019 I've been using React Hooks, I haven't had to use the this
keyword once.
Learn More About React Hooks On official website.
React Hooks.
Do you like React Hooks too?
Let's discuss it more in the comments section. If you agree don't forget to like ❤️ and save ?
?Keep Focused And Just Code It!
This content originally appeared on DEV Community and was authored by Chetan Atrawalkar?CA.
Chetan Atrawalkar?CA. | Sciencx (2021-07-20T05:57:51+00:00) ?Most Confusing Part Of JavaScript.. Retrieved from https://www.scien.cx/2021/07/20/%f0%9f%a7%90most-confusing-part-of-javascript/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.