Javascript

  1. 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

    Image Upload 1
  2. Six basic values
    • 1. Numbers
    • 2. Strings
    • 3. Booleans
    • 4. Objects
    • 5. Functions
    • 6. Undefined Values
  3. 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:Image Upload 2
  4. 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)Image Upload 3
  5. 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.
  6. Straight Control Flow
    the statements are executed, predictably, from top to bottomImage Upload 4
  7. Conditional execution
    An alternative is conditional execution, where we choose between two different routes based on a Boolean value, like this:

    Image Upload 5
  8. Multiple if/else statements
    If we have more than two paths to choose from, multiple if/else pairs can be “chained” together
  9. Loop
    Endless loop

    Image Upload 6
  10. 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.Image Upload 7
  11. Function Expression
    The code below is a function expression: var x = function () { }
  12. named function expression
    function foo() { }
  13. Anonymous function
    a function without a name
  14. 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;}
  15. Variables
    belong to the local or global scope. Private variables can be made possible with closures.
  16. 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.
  17. Closure
    • A function that “closes over” some local variables is called a closure. This behavior not only frees you from having to worry about lifetimes of variables but also allows for some creative use of function values.
    • Example:
    • Image Upload 9
    • Image Upload 11
    • Image Upload 13
  18. 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
  19. 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"};
    • valuesImage Upload 14
  20. 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.

    Image Upload 15
  21. 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.
  22. Array push() method
    Add element to the end of an array
  23. Array pop() method
    Removes element at the end of an array
  24. Array unshift() method
    Adding element to the start of an array
  25. Array shift() method
    Remove element from the start of an array
  26. Array slice() method
    Takes a start index and an end index and returns an array that has only the elements between those indices
  27. Array concat() method
    Glue arrays together, similar to what the + operator does for strings.
  28. String property toUpperCase
    returns array in uppercase
  29. String property length
    returns the length of the string
  30. String property slice
    Takes a start index and an end index and returns a string that has only those elements between those indices
  31. string property indexOf
    Returns the position of the first occurrence of specified value. Can contain more than one characterImage Upload 16
  32. trim() method
    Removes whitespace (space, newlines, tabs, and similar characters) from the start and end of a string
  33. charAt() method
    Access individual characters in a string. It also reads numeric properties like you'd do for an arrayImage Upload 17
  34. 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. Image Upload 18
  35. typeof
    operand is an expression representing the object or primitive whose type is to be returned.
  36. 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.
Author
jasminep16
ID
305004
Card Set
Javascript
Description
javascript language
Updated