• Programming,  Web Development

    Operator precedence

    Operator precedence determines the way in which operators are parsed with respect to each other. Operators with higher precedence become the operands of operators with lower precedence. More information: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Operator_Precedence

  • Programming

    Conditional Statement

    If the first character in string  is in the set , then return A. If the first character in string  is in the set , then return B. If the first character in string  is in the set , then return C. If the first character in string  is in the set , then return D. Switch function getLetter(s) { let letter; switch (s.charAt(0)) { case’a’: case’e’: case’i’: case’o’: case’u’: return’A’; break; case’b’: case’c’: case’d’: case’f’: case’g’: return’B’; break; case’h’: case’j’: case’k’: case’l’: case’m’: return’C’; break; case’n’: case’p’: case’q’: case’r’: case’s’: case’t’: case’v’: case’w’: case’x’: case’y’: case’z’: return’D’; break; } return letter; }

  • Programming,  Web Development

    Script loading strategies

    A common problem is that all the HTML on a page is loaded in the order in which it appears. In the internal example, you can see this structure around the code: document.addEventListener(“DOMContentLoaded”, function() { … }); This is an event listener, which listens for the browser’s “DOMContentLoaded” event, which signifies that the HTML body is completely loaded and parsed. In the external example, we use a more modern JavaScript feature to solve the problem, the async attribute, which tells the browser to continue downloading the HTML content once the <script> tag element has been reached. <script src=”script.js” async></script> If your scripts can run independently without dependencies then use async. If your scripts depend on…