Pure JS Flashcards
A primitive data type that represents the absence of a value.
null
A primitive data type that is the value of a variable or object that has not been initialized, or of a function that returns no value.
undefined
A block of JavaScript code that you define once, and can invoke over and over again.
Function
A function defined in an object
Method
Name the all the Primitive Types
Numbers, Strings, Booleans, Null, and Undefined
Name the Object Types
Arrays, Functions, and Objects
Functions that are written to be used (with the new
operator) to initialize a newly created object.
Constructor
Any JavaScript type that can be changed, like objects and arrays.
Mutable Type
Any JavaScript type that cannot be changed, like numbers, strings, booleans, null
, undefined
.
Immutable Type
Variables declared inside a function have function scope and are visible only to code that appears inside that function.
Local Scope
A global primitive number that represents when something is not a number
NaN
Values that evaluate to boolean true or false but that aren’t actually boolean values of true or false.
Truthy or Falsey
Truthy Examples
Everything that is not “Falsey”
Falsey Examples
false, 0, “” (empty string), null, undefined, NaN
Boolean Comparison Operators
&&
(and), || (or), ! (not)
Globally defined symbols that are available to a JavaScript program like undefined, Infinity, NaN, isNaN(), parseInt(), eval(), Date(), RegExp(), String()
Global Object/Global Function
Literal
A data value that appears directly in a program
What is an Immediately-Invoked Function Expression?
(function(){ // …do something… })();
What is a Closure?
A function that returns another function. It makes it possible for a function to have “private” variables.
Function Declaration
function doSomething(){ // …do something… };
Function Expression
var doSomething = function(){ // …do something… };
Boolean
Something with the value of True or False
Statement
var statement = “I am a statement”; console.log(“I am also a statement!”); myFunction(); // I am a statement too; Statements are the instructions of a computer program – they are executed by the computer and perform some action or computation.
Fixed Values
Literals ex: Numbers, strings, expressions
Variable Values
Variables are used to store data values for a later time. Ex: var myVariable = “literal string”;
Reserved Words
words that have special meaning attached to them. There are dozens. a few examples are: break, for, if, null, etc…
Comments
// This is a one-line comment /* This is a multiple line (or block) comment */
camelCase
JS convention where you capitalize every new word besides the first. Ex: thisIsAnExampleOfCamelCase
Equality Operators
=== or !==
Comparison Operators
, >=, <=
Order of Operations
(), !, &&, ||; // in that order
Ternary Operator
variableToSet = (conditionToCheck) ? :
== vs. ===
The difference is that === will also check to make sure the ‘type’ of the two operands are the same. Example: 0 == “0” // true 0 === “0” // false
code that repeats the doing of a specific task one or more times based upon certain conditions
loop
Types of loops
While, do, for
While Loop
performs a task for an unknown number of iterations, but while a condition is true. Example: var num = 0; while(num <= 100){ console.log(num); num++; }
Do Loop
same as while loop, but performs the task at least one time in spite of the conditions veracity. Example: var num = 105; do { console.log(num); num++; } while (num <= 100);
For loop
performs a task for a specified number of iterations. Example: var echo = “hello…”; for (var i = 0; i >= 0; i++){ console.log(echo); }
Break
Reserved keyword that ends a loop early. Example: var count = 0; while (true) { console.log(count); count++; if (count > 10) break; // exit the loop }
IIFE
Immediately-invoked Function Expression
null
A primitive data type that represents the absence of a value.
undefined
A primitive data type that is the value of a variable or object that has not been initialized, or of a function that returns no value.
Function
A block of JavaScript code that you define once, and can invoke over and over again.
Method
A function defined in an object
Numbers, Strings, Booleans, Null, and Undefined
Name the all the Primitive Types
Arrays, Functions, and Objects
Name the Object Types
Constructor
Functions that are written to be used (with the new
operator) to initialize a newly created object.
Mutable Type
Any JavaScript type that can be changed, like objects and arrays.
Immutable Type
Any JavaScript type that cannot be changed, like numbers, strings, booleans, null
, undefined
.
Local Scope
Variables declared inside a function have function scope and are visible only to code that appears inside that function.
NaN
A global primitive number that represents when something is not a number
Truthy or Falsey
Values that evaluate to boolean true or false but that aren’t actually boolean values of true or false.
Everything that is not “Falsey”
Truthy Examples
false, 0, “” (empty string), null, undefined, NaN
Falsey Examples
&&
(and), || (or), ! (not)
Boolean Comparison Operators
Global Object/Global Function
Globally defined symbols that are available to a JavaScript program like undefined, Infinity, NaN, isNaN(), parseInt(), eval(), Date(), RegExp(), String()
A data value that appears directly in a program
Literal
(function(){ // …do something… })();
What is an Immediately-Invoked Function Expression?
A function that returns another function. It makes it possible for a function to have “private” variables.
What is a Closure?
function doSomething(){ // …do something… };
Function Declaration
var doSomething = function(){ // …do something… };
Function Expression
Something with the value of True or False
Boolean
var statement = “I am a statement”; console.log(“I am also a statement!”); myFunction(); // I am a statement too; Statements are the instructions of a computer program – they are executed by the computer and perform some action or computation.
Statement
Literals ex: Numbers, strings, expressions
Fixed Values
Variables are used to store data values for a later time. Ex: var myVariable = “literal string”;
Variable Values
words that have special meaning attached to them. There are dozens. a few examples are: break, for, if, null, etc…
Reserved Words
// This is a one-line comment /* This is a multiple line (or block) comment */
Comments
JS convention where you capitalize every new word besides the first. Ex: thisIsAnExampleOfCamelCase
camelCase
=== or !==
Equality Operators
, >=, <=
Comparison Operators
(), !, &&, ||; // in that order
Order of Operations
variableToSet = (conditionToCheck) ? :
Ternary Operator
The difference is that === will also check to make sure the ‘type’ of the two operands are the same. Example: 0 == “0” // true 0 === “0” // false
== vs. ===
loop
code that repeats the doing of a specific task one or more times based upon certain conditions
While, do, for
Types of loops
performs a task for an unknown number of iterations, but while a condition is true. Example: var num = 0; while(num <= 100){ console.log(num); num++; }
While Loop
same as while loop, but performs the task at least one time in spite of the conditions veracity. Example: var num = 105; do { console.log(num); num++; } while (num <= 100);
Do Loop
performs a task for a specified number of iterations. Example: var echo = “hello…”; for (var i = 0; i >= 0; i++){ console.log(echo); }
For loop
Reserved keyword that ends a loop early. Example: var count = 0; while (true) { console.log(count); count++; if (count > 10) break; // exit the loop }
Break
Immediately-invoked Function Expression
IIFE