Yes, that is true. You canot use the arguments object in arrow function. But if you want to access the arguments object in an arrow function, you can use the rest parameters feature.
See the example bellow:
Happy coding.
Yes, that is true. You canot use the arguments object in arrow function. But if you want to access the arguments object in an arrow function, you can use the rest parameters feature.
See the example bellow:
Happy coding.
In this post I am going to talk about conditional import module in JavaScript ( ECMAScript modules ).
The import statemen in JavaScript is static and therefore has two limitation:
In case you need conditional import you can use async dynamic import. Async import can be performed at runtime using special import() function.
The module identifier can be any module identifier supported by static import.
Let see example:
This form also supports the await keyword:
Async/ await is cool feature in JavaScript. Much has been written about it. In this post I would like to show how to resolve more independent async functions calls.
Let's have a simple promise call. It takes 1 second.
Now we will call the function multiple times using await. It takes aproximately 10 seconds.
When our asynchronous function is independent, it is useful to use Promise.all() instead of await. It fulfilled all promises in time approximately 1 second.
I think, that closures are very handy for recursive call.
When you create a recursive function, keep in mind that there must be an escape from the recursive function, otherwise you will get into an infinite loop.
Below I created a function, which call yourself. Recursion can be very complex, but the principle is the same.
Try it yourself:Hey guys! Do you know about details and summary HTML5 tags?
This creates a simple accordion on your website. It si simple and elegant, isn't it?
Example:
Hey guys! Do you know if statement? Of course yes! But do you know lookup map? It's an elegant way to solve a multiple conditions.
Instead of using if..else, switch, we can define in advance a lookup table of values based on certain key.
Let's look at an example:
Modern applications should be vertically scalable. In this case, we use a load balancer, which forwards requests to individual nodes. Each node can be one application. The data is stored in a database that replicates between nodes. Almost any database engine - SQL and NoSQL - allows you to replicate a database. However, the most suitable for replication are modern NoSQL databases such as Redis, Amazon SimpleDB, MongoDB.
JWT have been introduced as a method of communicating between two parties securely. Even though you can use JWT with any type of communication method, today JWT is very popular for handling authentication and authorization via HTTP.
Simply put, you take the data and create a fingerprint from it. You attach the fingerprint to the data and send the data. The recipient receives the data, creates a fingerprint from it and compares it with your fingerprint. If the fingerprints are the same, the data are valid.
There are more details. The token is divided into three blocks: header, payload and signature. The header contains information about the encryption algorithm used. Payload may contain additional information, such as creation time and expiration time. But it mainly contains data.In the case of authentication service, the data is about a user. For example email, name, id. The last part contains the signature. The entire token is base64 encoded.
Token
The Pimp is lightweight authentication server based on JSON Web Token under the MIT licence. It is written in JavaScript on the NodeJS engine. It uses MongoDB to store data. In addition to the public API, it includes user management, token management, and event logging.
Public API
For more details, please visit the project at the Github.