Spread & Rest in JavaScript

The spread operator allows for an Object's properties to be filled into a another object right in line with existing properties. Likewise, this can fill one array in another array keeping the values in line with existing values. Spread const aNewObject = {...oldObject} const aNewArray = [...oldArray] Rest The rest parameter an array made  MORE q

By on April 18th, 2020 in

Map Data Structure in JavaScript

The Map object holds key-value pairs like a standard object. There are a few significant differences between Map and a regular key-value pair object. These are: Objects: Keys must be obtained and used to iterate over. Map: This is iterable, meaning we can directly iterate. Objects: The key can only be an integer, string, or symbol. Map: Key field can be of any data-type including objects and functions. Objects: Retrieving size is a manual process. Map: The size property hold this info. Objects: Iterating will not always return keys in  MORE q

By on April 17th, 2020 in

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

Reserved Keywords in JavaScript

There are words used in JavaScript that are intended only for very specific purposes. These keywords are needed to allow for JavaScript to have built-in functionality and standardized syntax. An example would be if. When writing in English, using if  has an expected outcome: "Dinner will be cold if you wait too long". This sentence  MORE q

By on April 15th, 2020 in

Programming Methodologies in JavaScript

OOP uses inheritance, via super-classes and sub-classes, and structures code around "what something is". The approach is similar to packing everything each item will need in a box, then only pulling out what is needed when it is needed. Basic QualitiesOnly a few functions work on common data. Uses an inheritance model. Object state can be modified. Functions use side-effects. Three potential problems with an inheritance model:Sub-classes might only need (or perhaps should only use) one method, yet they still absorb all methods from the parent classes. There is potential fragility if changes to a super-class has unforeseen affects on a sub-class. The state of an object and function side-effects can become difficult to manage as projects get larger. Functional Programming uses composition, via an  MORE q

By on April 15th, 2020 in

Post Navigation