-
Bit
A bit is the basic unit of information in computing and digital communications.[1] A bit can have only one of two values, and may therefore be physically implemented with a two-state device. These values are most commonly represented as either a 0or1. The term bit is a portmanteau of binary digit. Image represents the number 13
-
Six basic values
- 1. Numbers
- 2. Strings
- 3. Booleans
- 4. Objects
- 5. Functions
- 6. Undefined Values
-
Expression
An expression produces a value and can be written wherever a value is expected, for example as an argument in a function call. Each of the following lines contains an expression:
-
Statements
Roughly, a statement performs an action. Loops and if statements are examples of statements. A program is basically a sequence of statements (we’re ignoring declarations here)
-
The Environment
The collection of variables and their values that exist at a given time is called the environment. When a program starts up, this environment is not empty. It always contains variables that are part of the language standard, and most of the time, it has variables that provide ways to interact with the surrounding system.
-
Straight Control Flow
the statements are executed, predictably, from top to bottom
-
Conditional execution
An alternative is conditional execution, where we choose between two different routes based on a Boolean value, like this:
-
Multiple if/else statements
If we have more than two paths to choose from, multiple if/else pairs can be “chained” together
-
Loop
Endless loop
-
Updating variables succinctly
Especially when looping, a program often needs to "update” a variable to hold a value based on that variable’s previous value.
-
Function Expression
The code below is a function expression: var x = function () { }
-
named function expression
function foo() { }
-
Anonymous function
a function without a name
-
Function Declarations
Declared functions are not executed immediately. They are "saved for later use", and will be executed later, when they are invoked (called upon).
function myFunction(a, b) {return a * b;}
-
Variables
belong to the local or global scope. Private variables can be made possible with closures.
-
Call Stack
Because a function has to jump back to the place of the call when it returns, the computer must remember the context from which the function was called. The place where the computer stores this context is the call stack. Every time a function is called, the current context is put on top of this “stack”. When the function returns, it removes the top context from the stack and uses it to continue execution.
-
-
Recursion
It is perfectly okay for a function to call itself, as long as it takes care not to overflow the stack. A function that calls itself is called recursive
-
Objects
- Think of it as a Car object. A car has properties like weight and color, and methods like start and stop. Objects are variables too. But objects can contain many. Objects syntax: var car = {type: "value", model: "value"};
- values

-
Properties
The name:values pairs (in JavaScript objects) are called properties. Properties whose names are not valid variable names or valid numbers have to be quoted.
-
curly braces
This means that curly braces have two meanings in JavaScript. At the start of a statement, they start a block of statements. In any other position, they describe an object.
-
Array push() method
Add element to the end of an array
-
Array pop() method
Removes element at the end of an array
-
Array unshift() method
Adding element to the start of an array
-
Array shift() method
Remove element from the start of an array
-
Array slice() method
Takes a start index and an end index and returns an array that has only the elements between those indices
-
Array concat() method
Glue arrays together, similar to what the + operator does for strings.
-
String property toUpperCase
returns array in uppercase
-
String property length
returns the length of the string
-
String property slice
Takes a start index and an end index and returns a string that has only those elements between those indices
-
string property indexOf
Returns the position of the first occurrence of specified value. Can contain more than one character
-
trim() method
Removes whitespace (space, newlines, tabs, and similar characters) from the start and end of a string
-
charAt() method
Access individual characters in a string. It also reads numeric properties like you'd do for an array
-
Global Object
The global scope, the space in which global variables live, can also be approached as an object in Javascript. Each global variable is present as a property of this object. In browsers, the global scope object is stored in the window variable.
-
typeof
operand is an expression representing the object or primitive whose type is to be returned.
-
Objects as maps
Can be associating values with names. The in operator can be used to find out whether an object contains a property with a given name. The same keyword can also be used in a for loop (for (var name in object) ) to loop over an object's properties.
|
|