Up and Going Flashcards
Javascript is to Java as
Carnival is to Car
Javascript gets its procedural roots from
C and a little Scheme/Lisp style functional roots
Definition of computer language
Rules for valid format and combinations of instructions ( aka syntax)
Code def
Set of special instructions to tell code what to do
Statement def
Group of words, numbers and operators to perform a specific task
Expression def
any reference to a variable or value
Call expression
A function
Interpreter or compiler def
A special utility on a computer that translates codes into commands
Interpretted vs compiled
Interpreted runs line by line. Compiled translates ahead of time and runs later
How does Javascript interpret/compile?
Compiles on the fly and runs the compiled code
+= -= are known as
Compound assignment. Combines a math operation with an assignment
== is called
loose equals
=== is called
strict equals
Basic types like boolean and string are refered to as
Primitive types
Conversion between value types is called
Coercion
To convert “42” to 42
Number(“42”)
Comments should explain
Why not what
Static typing is AKA
type enforcement
Strong typing
Variable type cannot change (like string to integer)
Weak typing
Variable type can change
Weak typing is AKA
dynamic typing
Primary purpose of variables
To manage program state
To make variable foo 245.654 to 2 decimal places
foo.toFixed(2)
Block def
A series of statements put together
Falsey def
Anything that is false in a boolean
Technical term for scope
Lexical scope
Scope def
Collection of variables and rules for variables accessible by name
To find type of foo
typeof foo
typeof returns which possible types (7 as of ES6)
undefined string number boolean object function
Why is typeof null an object?
Long standing bug with too much legacy to change
obj[“a”] style and obj.a style names
bracket notation and dot notation
to make uppercase
sting.toUpperCase()
Explicit coercion
You can see in code a type conversion
Example:
a = “42”
a = Number(a)
To convert string to number
Number(“12”)
Implicit Conversion
Cannot see the coercion in code Example: a = "43" a = a + 1 a === 44
Falsy values in JS
"" 0 null undefined false
Difference between == and ===
== checks for value with coercion allowed === checks for value and type
A non-number string and a number with a comparison operator will always return
eg “a” > 3
False
What are reserved words?
names that variables cannot have such as true or for
Hoisting def
When a variable is declared to belong to the entire scope
Why add a break to switch statements?
Cases will run with any matches. It’s not like if statements
The one line if statement is known as the
“conditional operator” or “ternary operator”
IIFE sf
Immediately Invoked Function Expressions
What is a polyfill?
a new feature and producing a piece of code that’s equivalent to the behavior but is able to run in older JS environments
Transpiling def
tool that converts your newer code into older code equivalents
3 reasons to use new syntax even though it is transpiled (by things like babel)
Easier to read
Easier to maintain
Optimized for new browsers
What is document in document.getElementBy
Global variable for browser code. It’s a special object often called a Host Object
About the getElementById()
Not a normal JS function. It is an enterface built into the DOM from the browser
Treaditionally the DOM and it’s objects were written in
C/C++
Closure def
A way to remember and access a function’s scope
What is the authors criticism of JS developers?
Serious developers in other languages put huge effort into learning the language whereas JS developers get content with their minimal amount
Generators are
pausing yielding points in JS functions to be resumed asynchronously later