JavaScript Functions Flashcards

1
Q

HTML Rendering

A
  1. Reads top to bottom - rendering 1 line at a time.
  2. As each item is found (image, css, js, etc.) it downloads it.
  3. While each line is downloaded and rendered it blocks
    blocking means that everything else is put on hold until it completes.
  4. JavaScript is downloaded, concatenated into a single file in the order each part is retrieved, global variables declarations and functions are then hoisted, and all the JavaScript is treated as a single script. Statements in the global scope are run as they are loaded preserving the Lexical Order.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Anonymous Functions

A
  1. Anonymous functions have parameters and a code block but do not have a name.
  2. Can be assigned to variables
  3. Can use the function keyword:
    a. const doubleSum = function (x, y) {
    let val = (x + y) * 2;
    return val;
    }
    doubleSum(2, 4);
    b. or the the fat arrow operator ( => )
    const trippleSum = (x, y) => {
    let val = (x + y) * 3;
    return val;
    }
  4. Equivalent except for this keyword
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Array forEach() function

A
  1. Loops through the values in the array 1 at a time, similar to a Java for each.
  2. Takes an anonymous function as an argument, that function will be passed 3 arguments:
    a. Current value
    b. index
    c. array
  3. Does not return a value
How well did you know this?
1
Not at all
2
3
4
5
Perfectly