10 razones para usar Whatsapp Business en 2020

2020 no ha sido amable con las empresas, especialmente si se encuentra en el sector de la hospitalidad y el turismo. Sin embargo, las cosas están lejos de terminar para estas empresas. Varias otras…

Smartphone

独家优惠奖金 100% 高达 1 BTC + 180 免费旋转




Modern Java Script

Lets say that a variable is hidden outside of its defined boundaries. In the bellow code snippet, scope of the variable of k is within the for loop only.

When we use var in here it will print without any error but when we using a lengthy code, then we cannot find the error in the code since the scope of car is high. So we use let, that it guaranteed that it is efficient inside that {} in the code. Not only var we can use const also. It will also face the same issue while we declare the variable inside for loop. When we using const outside the loop then in the declaration row we have initiate the const variable there otherwise it will give an error.

In the above code gives an error because const is initialized in line 1 and again it will initiate in line 4.

If we change the const to let it will not be popup for any error.

Const is only protecting a variable until that is not a object or array.

You can see the above code, we cannot assign a new value to a const variale once it assign. But are able to use array which is constant and add more values.

In a constant array or object we can add or change the value without any error.

Arrow Function.

Functions can be simplified by using arrow functions. When we passing two arguments we need to have brackets. But if there is only one argument brackets are not required.

If we write a function by using this keyword, represent the caller function. But if we use arrow functions, this keyword will not represent the caller function like bellow image.

Object Handling

We can have a place holder as a key if we don’t want what the key would be at the execution time is called as Dynamic Property.

Key can be highly dynamic we don’t know what the key would be when we send an object through a service. we can have a placeholder like below and whatever comes from the service we can assign it to the placeholder here.

In the above image we can see SQRT2 in line 9 doesn’t need to have a value because in line 1 it already assign a value.

Once we enable the dynamic property in line 8 it will prompt an error like bellow.

To solve that we can have a placeholder as below as a key if we don’t now what the value would be at the execution time.

Object Freezing

We can re-assign values to objects very easily like bellow.

If we uncomment the line 3 freeze method then it will compile like bellow.

In the Freeze method freeze only the first level values. It does not freeze inner level values. It will show in bellow image.

As you can see name is first level variable and t1 and t2 are second level variables. Freeze only apply for first level variable like name only. That is why name not changed.

Override Functions.

We can override the function with anything wen call through object. We can have functions in classes but when in runtime we can override functions when we want.

Destruct

Instead of demonstrating here, we could just write PI and SQRT2 the same way by using math class.

When calculating area, we simply need a basis; no additional variables are required. We pass the object while supplying parameters, yet it calculates the area without any issues.

As you can see, when this is executed, two text files are created. Here, we have the option to disregard fs and just write it when using destruct.

Promise

Http GET occasionally connects to the server and requests a response, the code must be wrapped in a promise as seen below. This will trigger the promise when it is completed if it is wrapped in a promise.

This will result in undefined if the below function is used in place of the catch finally block. This is included within a promise object, but we first declare the length. Typically, we don’t wait for the outcome in this situation. This does not await the fulfillment of the promise.

This will return a promise object and wait until the promise is resolved by using the fetch web page. Once the promise was fulfilled, it moved on to the next one. If the await keyword is removed, it will become undefined.

The term “await” is only valid inside an async function. Removing the async keyword makes await ineffectively.

Add a comment

Related posts:

Olive Oil

My first reaction was to disagree with that, thinking that the fire would alter its essence, seemed like a waste. But I think I understand why, and I belive I have been undervaluing olive oil, in…

The code that lasted for 12 hrs

I am writing this blog to share about an experience I recently had for building a web application and how it went through. From getting awesome traffic to a complete flop show. One fine day a friend…

Small Finance Banks in India

It all started with Local Area Banks (LAB) back in 1996 — an initiative by the then Prime Minister to operate locally in semi-urban and rural areas (Tier 3 and Tier 4 cities) — where people are…