10 JavaScript concepts that you need to succeed with the knot

Json

It is difficult to imagine JavaScript and a node without JSON, which means notation of the JavaScript object. In fact, it is difficult to imagine a modern programming universe inside. It is a simple but incredibly versatile means to describe and share data between applications.

The foundations are simple:


{ 
  “artist”: “Rembrandt”,
  “work”: “Self Portrait”,
  “url”: “https://id.rijksmuseum.nl/200107952”
}

There is nothing much to see here; Just a few curly braces and a column called PEIR. You can also have fields and other JSON objects for complete charts of objects. But in addition, there are many techniques and tools for handling JSON, starting with the building in JSON.stringify and JSON.parseturn Json into straps or vice versa.

Json is more or less Way Sending data via the wire, from the customer to the server and elsewhere. It is now also common in data data, especially for NOSQL databases such as Mongodb. Comfortable with JSON will cause the programming in the knot to be much more smoother.

Errors processing

Good errors processing is a key concept in the node. You stimulate two types of bugs in the node: standard Runtime type and asynchronous species.

While the mistakes of the asynch. Promises Are processed by using the use .catch() Call back, normal runtime errors are solved try/catch Keyword blocks:


try {
  /* do something risky */
} catch (error) {
  /* do something with the error */
}

If an error occurs during an asynchronous operation, this call will make this call and receive an error object.

When used async/awaitYou are using the standard try/catch The blocks.

Conceptually, it should be remembered that it will go wrong, and catching errors is the main way to add it. We want to restore the operation if possible. Otherwise, we want the error status to be as painless as we can for the end users. If possible, we also want to record the error. If we interact with an external service, we can be able to return the error code.

The best errors processing is dictated by circumstances. The main thing is to keep mistakes in the back of your mind. It is an error conditions that we do not think that they usually get us, more than those we think about and we are wrong. Also beware of “swallowing” errors to define and catch A block that doesn’t do anything at all.

Keep it flexible

At the beginning of this article, I mentioned that JavaScript will handle a number of programming styles. These are functional, object -oriented, reactive, imperative and program. Here we have a huge range of powerful concepts – some of the most important in programming. In the next paragraph we cover each of them in detail …

I’m just kidding! There is no way of justice for all these programming styles, even in the treatment of a book. The main point is that JavaScript is flexible enough to accept all of you. Use what you know and be open to new ideas.

Often you will face the work you need to do, and there is always more than one way to do it. It is normal to worry that there is a cooler, faster or more efficient way to complete the work. You must find a balance between work now and exploring newer technologies and proven procedures for later.

When you add your understanding, you will naturally find tasks and areas in which some paradigms are useful. Someone who really loves programming will not be able to indulge (many) in the “My Paradigma/Tool/Frame” game. A better approach that will serve you during your career is: “This is the best tool I know for this work right now, and I’m open to improvement.”

Like any other good discipline – Say Music or Martial Arts – a real master knows that it is always necessary to discover. In this case, the practice is being built JavaScript on the server side with a knot.

Leave a Comment