
JS developer in a few minutes.
JavaScript it is easy and pleasant language. In this article, I will show how to write modern JS. If you have some programming experience and want to start coding JS right now this article is for you:) I will not try to show whole JS in this tutorial, but only main concepts and patterns.
Motivation
If you learn JS once, it will serve you after. Not only because of the web: you may find it useful in a huge scope of problems such as writing video games and back-ends, building robots, doing calculations and many others.
Declaring variables
You have two ways to declare variables it is const and let keywords(var is dead). Rule of thumb it is always used const and when you need to change variable - think twice about why you need to change this variable, and if you really need - change const to let. const means that you can’t re-declare this variable, but you can change the properties of one.
Functions
You have two ways to make functions. Using arrow-like syntax or using the function keyword. They have one difference inside. When you use arrow-like function this will be taken from the context of a declaration.
Objects
I will show in the example.
Classes
JS has a class keyword. Better ignore his existence. You will see later how to live in JS without classes.
Concurrency
JS has only one thread to run your program. And one of the coolest parts of the language is how it solves parallel tasks. While waiting for the response from the server, or user i/o, JS try to complete other possible work. When the response comes, the thread already knows it and will jump to process it after completing the current task.
Patterns
Factories over classes.
Interfaces for functions
JS doesn’t have native interfaces, but you can send an object as parameter this way(object distraction).
No loops
JS have loops but you will have better experience writing code without loops. JS, it is all about functions and Array have a lot of staff such as a map, reduce, filter…
Objects merging
Pure functions
Never change the object inside the function — it is evil. You understand why.
Functional programming staff
JS, it is a very good place for functional programming, since it has all the main properties of functional language. Yes, there is no immutability in JS, but you can easily make it immutable.
Reach the next level of focus and productivity with increaser.org.
