A gentle reminder, sucking at something is the first step to learning something new…
Expressions:
- Code snippets that can be evaluated to a value.
- Used with operators to perform operations on values.
- JavaScript has several types of operators, including arithmetic, comparison, logical, assignment, bitwise, and string operators.
- Precedence rules determine the order in which operators are evaluated in expressions.
- Grouping operators, like parentheses, can be used to override precedence rules and force certain operations to be performed first.
- Special operators, like the ternary operator, can be used to write more concise and readable code.
- JavaScript has several built-in objects, like Math and Date, that provide useful functionality for performing operations and working with specific types of data.
- The typeof operator can be used to determine the type of a value or variable.
- The instanceof operator can be used to determine if an object is an instance of a particular class or constructor.
- JavaScript also supports several types of literals, like string literals, number literals, boolean literals, and null and undefined literals.
- The delete operator is used to delete a property from an object or an element from an array.
- The void operator is used to evaluate an expression and then return undefined.
- The comma operator is used to separate multiple expressions and evaluate them from left to right, returning the value of the last expression.
- The eval() function can be used to evaluate a string as JavaScript code.
- The in operator is used to check if an object has a property with a specific name.
- The instanceof operator can be used to check if an object is an instance of a specific constructor.
- JavaScript also supports a set of conditional (ternary) operators that allow for more concise code.
- The strict equality and inequality operators (=== and !==) check if two values are of the same type and have the same value.
-
The logical AND (&&) and logical OR ( |
|
) operators perform short-circuit evaluation and can be used to conditionally execute code based on the truthiness or falsiness of values. |
- The bitwise operators perform operations on binary representations of values.
- The typeof operator returns a string indicating the type of the unevaluated operand.
- The void operator evaluates an expression and then returns undefined.
- The yield operator is used in generator functions to yield a value to the generator’s caller.
Loops and Iteration:
- Used to repeatedly execute a block of code while a certain condition is true.
- JavaScript supports several types of loops, including the for loop, the while loop, and the do-while loop.
- The for loop is the most commonly used type of loop in JavaScript, and is used to execute a block of code a specified number of times.
- The while loop is used to repeatedly execute a block of code while a certain condition is true.
- The do-while loop is similar to the while loop, but it guarantees that the block of code is executed at least once, even if the condition is false.
- The break statement can be used to exit a loop early.
- The continue statement can be used to skip over a single iteration of a loop.
- The for…in loop can be used to loop through the properties of an object.
- The for…of loop can be used to loop through the values of an iterable object, like an array.
- The forEach() method can be used to loop through the elements of an array and execute a function on each element.
- The map() method can be used to loop through the elements of an array and create a new array with modified values.
- The filter() method can be used to loop through the elements of an array and create a new array with only the elements that pass