Web Development for Beginners
-
hasURL https://docs.microsoft.com/en-us/learn/paths/web-development-101/
-
- ARIA
- "The controls for your page should be listed in the HTML source in the order in which you expect the page to be browsed, while relying on CSS to lay out the page visually to users."
-
javascript
let
is for block variablesvar
is for function-scoped variables- initialize = declare + assign
const
should get UPPER'd- The presence of const means the reference is protected from reassignment. But the value is not immutable and can change, especially if it's a complex construct like an object.
-
- camelCase your beautiful names
- why not use verbs?
-
- no parens! including parens means call it now (and pass return value?)
-
- use when the func wouldn't be used anywhere else
- presumably programmers occasionally convert anonymous functions into named functions
-
- aka: fat arrow functions
- replace the word
function
- Compared with ordinary functions (declared with the function keyword): hasSource https://javascript.plainenglish.io/3-scenarios-where-you-shouldnt-use-arrow-functions-862388acd05d
- An arrow function doesn’t have its own this value
- It doesn’t have the arguments object.
- It doesn’t have the
construct
internal slot.
-
- The for and forEach() loops both let you loop over the array's items, but the difference between them is that the for loop lets you exit if a certain condition is fulfilled
numbers.forEach((number, index) => console.log(
Number ${number} ${index}));
-
find()
- e.g.
iceCreamFlavors.find(flavor => flavor === "Chocolate") // "Chocolate"
- runs the function that you provided as input for each item. If the operation finds the searched-for element, it returns the element. If it doesn't find the element, it returns undefined.
- e.g.
-
filter()
- e.g.
iceCreamFlavors.filter(flavor => flavor.type === "Chocolate")
- e.g.
-
map()
(a projection)- "The map() method creates a new array with the results of calling a provided function on every element in this array."
-
reduce()
- reduces a long list of items into a single item