One Pager Cheat Sheet
- JavaScript's type coercion changes argument values to ensure that the correct types are used in expressions, both implicitly and explicitly.
- In JavaScript, explicit coercion occurs when a
value or expressionis explicitly converted to a different data type. - The
typeofoperator is used to determine the data type of a given value and return astringthat identifies itstype. - JavaScript provides a
typeofoperator that can examine a value and tell you its type. - Using
===allows you to compare two values and determine if they are equal and of the same type. - JavaScript has both strict and type-converting comparisons to check for value equality, with
strict comparisondisallowing coercion andabstract comparisonallowing it. - The scope in JavaScript determines the
visibilityandlifetimeof variables and functions, and defines how and where these variables can be accessed based on their context of declaration. - Variables in JavaScript are associated with a particular
scope, which determine their availability to code found lexically within a block and the ability to make their names unique among the same scope. - A
callbackis a flexible and modular programming pattern which increases code abstraction and maintains code maintainability. - A
callbackfunction is passed to another function as an argument and executed after some operation has been completed. - Strict Mode is a feature of ECMAScript 5 (ES5) that helps to prevent certain actions and make code more likely to throw exceptions when errors arise by using the
"use strict"statement. - The
use strictliteral helps to prevent errors by throwing an error if a global variable is created unintentionally. - No, a polyfill (also known as a
shim) is not a UI library in JavaScript; it is code thatreplicates the expected functionalityof modern browsers so that older browsers can also run a particular application or webpage. - Polyfills are pieces of code or plugins that enable modern functionality in browsers that have not implemented it natively, and it is not exclusive to
Javascript. - No
valueisintentionally absentwhennullis used, whileundefinedmeans thevariableisunassignedand hasnot been declared. - JavaScript and
TypeScripthave two bottom types,nullandundefined, which are intended to indicate different states of something either uninitialized or currently unavailable. - The code will output 5 because
bwas declared without thevarkeyword, making it globally available, whereasawas declared with thevarkeyword and was only available within the function. The code uses a variablebdeclared in **global scope** which allows it to output5even though it appears to be declared within a function.- The
propertyfooof theobjectxhas beendeleted, thereforex.foowill returnundefined. - The
deleteoperator is used todeletethefooproperty ofobject x, resulting inundefinedwhen attempting to reference it. - The
deleteoperator is used to delete a global variable of typenumber(in this case,x) from an object. - In JavaScript, any value that's not
null,undefined,"",0,-0,NaNorfalseis considered "truthy". - JavaScript's
hoistingbehavior allowsvariablesandfunctionsto be accessed before they are declared, though the actual values and logic within them remain in their original place. - Javascript moves all
declarationsto the top of the current scope, allowing a variable to be used before it has been declared, but only withvariable hoisting(less common) andfunction hoisting(more common). - The program outputs 0 because of the process of
function hoistingand the inability of thedeleteoperator to delete primitive values. - The
deleteoperator has no effect on local variables, so the output of this code will be0.

