Friday, May 18, 2018

What you absolutely need to know about JavaScript

When it comes to making websites HTML, CSS and JS are the three core technologies you need to know.
Both JS and CSS rely on the tree structure of the web page. The tree structure is represented with the Document Object Model (DOM).

Browser compatibility

Websites are rendered by the web browsers thus JS is also interpreted by the browsers, and this is why there are differences between their capabilities in interpreting JS.
You have two options here:
  • check for browser compatibility yourself e.g. in the MDN JS Reference
  • use a compiler/polyfill e.g. Babel to take care of compatibility for you

The standardized version of JavaScript is called ECMAScript. It has several editions since 1997. The 6th edition called ES6 and ES2015 added a significant new syntax and new libraries that generally make development easier, however it is not supported by all browsers.

The main browser compatibility issue is with Internet Explorer. Currently (2018/05) the only supported Internet Explorer version is IE11 and it only gets technical support and security updates from Microsoft - instead of being developed further it is replaced by Microsoft Edge.
If you want to support IE11 you have two options here:

Why you want to use the enhanced Javascript syntax

Probably the most important new feature of ES2015 is the use of promises instead of callbacks. This was then further simplified by the introduction of the async/await keywords in ES2017. Here is a demonstration of the above, and here is a guide to picking the right asynchronous way out of the three. 
If this is not enough see what else is in ES2015.

Frameworks and Libraries

There are many frameworks and libraries to help developers implement frontend applications. If you read How it feels to learn JavaScript in 2016 you'll get a general idea of how fast the frontend technology is changing.
Here are some recent trends:

Running Javascript outside of the browser

It is possible to use JS outside of the context of a web browser, for example it can be used to write server code or desktop applications. The most well known JS runtime environment is NodeJS. It has a package manager called npm.
If you want to run tests, compile code, do style checks it is a convenient way to run these commands and maintain these dependencies through npm.

Further readings

Documentation

No comments:

Post a Comment