Jul 19, 2024
command+opt+J
on Mac or Ctrl+Shift+J
on Windows.+
, Subtraction -
, Multiplication *
, Division /
.%
: Returns the remainder after division.**
: Raises one operand to the power of the other.let
, const
, and var
.
let
is used for variables that can be reassigned.const
is for constants that shouldn't change.var
is outdated and generally not recommended.+
.${expression}
).length
: Returns the length of the string.toUpperCase()
, toLowerCase()
: Change the case of the string.trim()
: Removes whitespace from both ends of a string.indexOf()
: Finds the position of a substring in a string.slice()
: Extracts a section of a string.replace()
: Replaces a substring with a new substring.repeat()
: Repeats the string a specified number of times.[]
with comma-separated values.push()
, pop()
: Adds/removes elements from the end.unshift()
, shift()
: Adds/removes elements from the beginning.concat()
, includes()
, indexOf()
, join()
, reverse()
, slice()
, splice()
, sort()
.{}
.for (initialization; condition; increment) { statement }
.while (condition) { statement }
.function
keyword.function name(parameters) { statements }
.const name = function(parameters) { statements }
.function(name = 'Anonymous')
.return
keyword to send a value back from a function.