Quiz

  1. jQuery

    Hmm. That's a big question. jQuery is great. It's well designed, well tested, simple to use and powerful.

    However, it's not as necessary as it was in the past. See the next question.

  2. I would like to see more of the differences between Native API and jQuery and why jQuery might be losing its traction.

    Well, we could poke around the you might not need jquery website. But I've already pulled out the handful of them that are relevant to us.

    Maybe we can think of jQuery as one of those multi-ended connectors, so you can connect to RJ-45, mini-usb, usb-A, usb-c, lightning, hdmi, vga, ...

    jQuery began because it brought consistent capabilities to a wide variety of browsers.

  3. In chaining methods together, is the order of the chaining important?

    Depends. Often not:

    
    $("selector").css('color', 'white').css('background-color', 'black'); 
    $("selector").css('background-color', 'black').css('color', 'white');
    
    

    But it might:

    
    $("selector").css('margin', '20px').css('margin-bottom', '30px'); 
    $("selector").css('margin-bottom', '30px').css('margin', '20px');// makes no sense
    
    

    Sometimes, it's not clear:

    
    $("selector").append("<li>").addClass("important");  // which is important?
    
    
  4. Which version of click are we expected to use? The function or the event?

    Hmm. I'm not sure what you mean. There are the following options:

    
        // w/ jQuery
        $("selector").click(functionName);
        $("selector").click(() => { function body });
        // w/o jQuery
        document.querySelector("selector").addEventListener('click', functionName);
        document.querySelector("selector").addEventListener('click', () => { function body} );
    
    
  5. Can you elaborate a bit more on when to use the function call vs. the value?

    Well, a function call is replaced by its value, so there's no difference there:

    
    const val = fun();
    
    

    But there is a difference between a function and its value:

    
        const v1 = fun();
        const v2 = fun;
        v1 == v2; // almost certainly false
    
    
  6. could you talk more about JS method querySelectorAll? is the document object/property(?) that this method is invoked on something that exists on every html page?

    The browser has a built-in value called document, and that has a method named querySelectorAll.

    You can count on that for any modern browser.

  7. also, what does this arrow function () => {} do?

    Nothing! It's a placeholder in an example, to say: your function here. Like I did above, except I put in function body.