Categories
Entertainment and Gaming

7 Simple Things I Learned about JavaScript

Featured photo: Image by Alltechbuzz_net from Pixabay

Hello all. Another weekend is upon us! Hope you all had a great week. Today I thought I’d go over a few little simple but interesting things I learned from JavaScript (so far). I am no expert in the language – yet at least – but I have come across some interesting little facts that I wanted to share.

1. The JavaScript Engine

Image by Michael Schwarzenberger from Pixabay

One of the first things I learned about was the JavaScript Engine and how it is different from one browser to the next. The names of these are important for developers to know so they can keep up to date about the latest JavaScript support for the browsers they use.

Some of these include V8 which is used by Google Chrome, Opera and Microsoft Edge.

SpiderMonkey used by Firefox.

And Chakra used by Internet Explorer… not that this one is really relevant anymore.

2. Languages can Transpile to other Languages

Image by PopcornSusanN from Pixabay

What this means is you can use a different language that may use syntax you prefer to write code in that can then be transpiled into JavaScript so you don’t actually have to write the JavaScript yourself.

It also has barely any impact on performance so there is little downside. Such languages that can transpile to JS include…

  • TypeScript which is developed by Microsoft.
  • Flow which is developed by Facebook Inc (or Meta as it is called now).
  • Brython – which transpiles Python code – which is one that sounds most interesting to me as I am interested in also learning Python.

3. The JavaScript Standard

The gold standard. Image by Steve Bidmead from Pixabay

The specification for JavaScript is ECMA-262 which you can read here. It is an in-depth dive into the language and which fully defines it. Although it basically includes anything you may want to know on JS – it is not for quick reference. Instead developer.mozilla is better for that.

You can also go to this GitHub page here to see proposals for JS – new features that have not yet reached Stage 4 (where they officially become part of ECMA-262).

4. Best Browsers for JavaScript Development

Image by Photo Mix from Pixabay

Many browsers include their own development tools to support JavaScript development. Such tools can be found by right-clicking and selecting ‘Inspect’ which brings up a console which can be used for debugging among other things.

Most developers consider Firefox and Google Chrome to have the best developer tools for JS support.

5. The Script Tag

Image by Boskampi from Pixabay

The Script tag – <script></script> is what is used to insert JS functionality into HTML (a markup language for structuring content on websites). Usually this is done by placing either a .js file or a url that contains the written JS.

But you can also write actual JS code within the tag as well (which I did not know beforehand). But it is to be noted this is rarely done since it can get messy if there is too much script (which there normally is a lot). Usually it is better to have it all organised in a file that is linked to the tag either by an absolute path or relative path.

Linking to a JS file or URL is also better for page load times – this is because the browser will download it once and then store it in cache – rather than downloading it every time when it is just written directly in the tag.

6. Semicolon Fun

Image by fancycrave1 from Pixabay

A semicolon is usually placed at the end of a line of JS code so the engine can run the code correctly without errors.

But semicolons can be omitted when a line break exists as the engine will add an ‘implicit semicolon’ itself. But it is suggested not to do this as sometimes the engine makes a mistake and doesn’t insert one where it is supposed to go – causing a hard to locate error.

As well as that code that has visible semicolons in the right places is also just easier to read and looks nicer.

7. Strict Mode

Strict as a ruler? Image by 2541163 from Pixabay

Once upon a time any new updates to JS would merely add new features while leaving older features untouched (some of which later become deprecated – which means don’t use them anymore although you still can if you really want to).

Anyway – this meant that compatibility issues were not really a thing in JS. That was until 2009 when ECMAScript5 altered/modified some existing features.

But there was an immediate solution to this – Strict Mode. Unless Strict Mode has been explicitly enabled for some code the engine will just treat it as if any alteration/modifications that had been introduced are not there.

Enabling Strict Mode is done just by putting “use strict”; above the code you want it to affect, or you can nest it in a function if you only want it to affect that one function.


I’ll stop there for now. But I do have more I’ll share in the future. I am looking forward to continuing my JavaScript journey.

Thank you for reading this post, if you have any queries please Email me, you can find my Email in the Contacts & Community section. Please also follow The Weekly Rambler on Twitter, Reddit, Pinterest and Facebook which you can access through the buttons at the bottom of this website. You can also use the social media buttons under each blogpost to share with your family, friends and associates.