Jul 21, 2024
<script> tagsconsole.log to print to the console for debugging// comment/* comment */undefined, null, boolean, string, symbol, number, objectvar, let, constlet and const introduced in ES6; const cannot be changedvar/let/const variableName = value;+-*/++--*+=-=*=/=*\, \n, \t, \", etc.+ and +=.lengthstring[index]var arr = [element1, element2];[[element1, element2], [element3, element4]]array[index]array[index] = newValuearray.push(element)array.pop()array.shift()array.unshift(element)function functionName(parameters) { // code }functionName(arguments);return keywordconst and letconst functionName = (params) => { // code };map, filter, reduce)function funcName(param1 = defaultValue1, param2 = defaultValue2) {...}(...args) => {...}[...array]const obj = { property1: value1, property2: value2 };obj.property or obj['property']obj.property = value or obj['property'] = valuedelete obj.property or delete obj['property']obj.hasOwnProperty('property')class ClassName { constructor(param) { this.property = param; } }if, else if, else statements==, ===, !=, !==, >, >=, <, <=&& (AND), || (OR), ! (NOT)condition ? exprIfTrue : exprIfFalseswitch(expression) { case value1: // code; break; case value2: // code; break; default: // code; }while loop: while(condition) { // code }do...while loop: do { // code } while(condition);for loop: for(initialization; condition; finalExpression) { // code }export { var1, var2, ... }import { var1, var2, ... } from 'file-path'export default functionNameimport functionName from 'file-path'import * as alias from 'file-path'*let allows block-scopingconst prevents reassignmentconst str = `Hello, ${name}!`;
const { a, b } = obj;
const [a, b] = arr;
const [a, b, ...rest] = arr;
new Promise((resolve, reject) => {...}).then() and .catch()