The this keyword

So I’m a beginner to JS, and coding in general, and I just reached the intermediate front-end projects stage, so I’m about to start my quote machine project soon. But I decided that before I did that, I’d try to study up more about JS from other sources, mainly to understand the bits I didn’t understand or wasn’t taught in the FCC course. Especially the JSON / API lessons, where I barely learned anything since the lessons were too vague and simply gave us the code to use instead of actually teaching anything. I’m having trouble with JSON and JS Objects, and one thing I really don’t understand is the ‘this’ keyword. I can’t find a good explanation for it anywhere, so I’ve come here to ask you guys to give me your explanation of the ‘this’ keyword. Plus, I’d highly appreciate a simple, easy-to-understand explanation of JSON and APIs.

Thanks!

@Quantomistro3178,
“this” keyword is a complex subject that has a lot of different meaning depending on the context of the usage of it.

I’d recommend you check the following links:

http://web.archive.org/web/20110725013125/http://www.digital-web.com/articles/scope_in_javascript/

https://stackoverflow.com/questions/3127429/how-does-the-this-keyword-work

2 Likes

@camperextraordinaire
@TomerPacific

Thanks a lot for the links!

“This” is a complicated topic, and the resources mentioned on it are great. I’ll give you some stuff for AJAX and JSON.

Free youtube series on Asynchronous JavaScript. When you deal with API’s, your knowledge of this topic will be a source of either frustration or ease depending on your skill. https://www.thenetninja.co.uk/courses/asynchronous-javascript-tutorial

JSON is just a data format. Basically, JavaScript objects that you can store as files. Because they are files, you can send them on a server, so they are the ideal way to send and recieve data from an API.

REST is a pattern for api’s. You don’t really need to worry about this until you build them yourself in the back-end section. REST is the most popular right now, but GraphQL is most likely the future of API’s. You don’t really need to worry about this. For all your needs, just GET the data from the server.