learn programming

This JavaScript

Pijalnia wody Lądek Zdrój

This week, I mainly studied the basics of JavaScript. I must have exaggerated with absorbing, I would have said more so that I absorbed it. The basics and understanding of how code works are important, but learning without coding is so tiresome.

What “this” in JavaScript means

Despite the fact that the basics can bore you, there are still a few positives. First, I finally understood what “this” in JavaScript is all about. While learning React, I couldn’t get what it was referring to using the “this” notation. Usually, it was an element contained in a method, but sometimes it turned out to refer to global variables. Now I know that it all depends on where in the code I use “this” in a function (a reference to a global variable) or in a method (a reference to a local variable). It is very counterintuitive, but most importantly, I understand why “this” does not always refer to a local variable, which frustrated me extremely learning React.

Hoisting, when a variable is available

Another interesting element of JavaScript is hoisting, which is why you can sometimes refer to a variable before it is declared and sometimes not. I may be weird, but I like to have some kind of order in the code. Specifically, I like to define variables first and then use them. Maybe I don’t have any mega experience in coding and I don’t create mega projects, yet this approach helped me find a bug in the code many times. Perhaps in JavaScript, you need to refer to something first and then define it, but at the current level of my knowledge, I do not know how to use something like that. Of course, it may be that I don’t know enough.

7 lines of JSON to made a magic

This week, I found an interesting proposition on the web: it is that thanks to seven lines of JSON code, you can turn a website into a native application that works on Android and iOS. Moreover, the author promises that the whole operation is not only about displaying the page in the native app frame. To be honest, my knowledge of PWA is small today. I know that there is such a thing and I know how to put basic information in a few lines of code that allows the user to save the page on the phone as an application. There is no chance that I would evaluate the author’s proposal for the code to automatically turn websites into PWA applications, at least for now. However, I think that the topic is interesting, so I am posting a link to the page where I found it: https://www.freecodecamp.org/news/how-to-turn-your-website-into-a-mobile-app-with-7-lines-of-json-631c9c9895f5/

So much for this week. Four hours of theory, mostly the basics. The DOM fun starts next week, so more will be happening.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.