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 expression
is explicitly converted to a different data type. - The
typeof
operator is used to determine the data type of a given value and return astring
that identifies itstype
. - JavaScript provides a
typeof
operator 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 comparison
disallowing coercion andabstract comparison
allowing it. - The scope in JavaScript determines the
visibility
andlifetime
of 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
callback
is a flexible and modular programming pattern which increases code abstraction and maintains code maintainability. - A
callback
function 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 strict
literal 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 functionality
of 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
value
isintentionally absent
whennull
is used, whileundefined
means thevariable
isunassigned
and hasnot been declared
. - JavaScript and
TypeScript
have two bottom types,null
andundefined
, which are intended to indicate different states of something either uninitialized or currently unavailable. - The code will output 5 because
b
was declared without thevar
keyword, making it globally available, whereasa
was declared with thevar
keyword and was only available within the function. The code uses a variable
bdeclared in **global scope** which allows it to output
5even though it appears to be declared within a function.
- The
property
foo
of theobject
x
has beendeleted
, thereforex.foo
will returnundefined
. - The
delete
operator is used todelete
thefoo
property ofobject x
, resulting inundefined
when attempting to reference it. - The
delete
operator 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
,NaN
orfalse
is considered "truthy". - JavaScript's
hoisting
behavior allowsvariables
andfunctions
to be accessed before they are declared, though the actual values and logic within them remain in their original place. - Javascript moves all
declarations
to 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 hoisting
and the inability of thedelete
operator to delete primitive values. - The
delete
operator has no effect on local variables, so the output of this code will be0
.