Asynchronous Code with JS

A promise returns the same data as a callback function, but can await the reply. With this, when there is a delay receiving data, the syntax is nicer and the better error handing. Most importantly, the browser can continue processing the page and then fill in the delayed data whenever it is ready. The above allows for JavaScript to step away from the normal synchronous processing order, which is running commands one after the other in the order   MORE q

By on April 17th, 2020 in

Scope in JavaScript

In English, "scope" is defined as: "The extent of the area that something is relevant". In JavaScript, this definition holds, with one small adjustment: "The extent of the area that something is accessible". With this in mind there are two basic areas with which a variable can be contained and is accessible: globally and locally. Global Scope Variables with global scope are part of the global object. In a web browser, this  MORE q

By on April 16th, 2020 in