JavaScript Tutorial
JavaScript is often abbreviated as JS. It is a scripting language for the web and supported by most web browsers such as Chrome, Edge, Firefox, etc. All web developers should know the basics of how to read, write, and troubleshoot JavaScript.
This tutorial will start with an introduction to JavaScript and will move through the basic components of the JavaScript language.
Prerequisites
There are no prequisities for this JavaScript tutorial. You should be able to easily understand this tutorial and learn the basic concepts of JavaScript as you progress to the more advanced JavaScript topics.
Now, let's get started learning JavaScript!
Or jump directly to a topic in JavaScript:
JavaScript Basics
Comments | Commenting code in JavaScript |
Literals | Literals such as string, number, boolean and null |
Reserved Words | List of reserved words that have special meaning |
Operators | Comparison, mathematical and assignment operators |
Variables | Declare variables and assign values |
Console Log | Console for debugging and troubleshooting |
JavaScript Loops and Conditional Statements
if-else | Execute code based on conditions |
switch | Execute code based on the value of an expression |
while loop | Execute code repeatedly (termination condition at start of loop) |
do-while loop | Execute code repeatedly (termination condition at end of loop) |
for loop | Execute code repeatedly for a fixed number of times |
for-in loop | Iterate through the properties of an object |
break | Terminate a loop early |
continue | Restart a new iteration of a loop (skipping remainder of current iteration) |
JavaScript String Methods
anchor | Create the HTML <a> element (or anchor) |
big | Create the HTML <big> element |
blink | Create the HTML <blink> element |
bold | Create the HTML <b> element |
charAt | Retrieve a character at a specific position in a string |
charCodeAt | Retrieve a Unicode value for a character at a specific position in a string |
codePointAt | Retrieve a Unicode code point for a character at a specific position in a string |
concat | Concatenate strings together |
endsWith | Determine whether a string ends with a specific substring |
fixed | Create the HTML <tt> element |
fontcolor | Create the HTML <font> element with a font color |
fontsize | Create the HTML <font> element with a font size |
fromCharCode | Create a string from a sequence of Unicode values |
fromCodePoint | Create a string from a sequence of Unicode code points |
includes | Determine whether a substring is found in a string |
indexOf | Find the location of a substring in a string |
italics | Create the HTML <i> element |
lastIndexOf | Find the location of a substring in a string, searching backwards |
localeCompare | Compare two strings and determine which string comes first in the sort order (based on locale) |
match | Find matches based on regular expression matching |
normalize | Convert a string to its Unicode Normalization Form |
padEnd | Pad the end of a string with a specific string |
padStart | Pad the start of a string with a specific string |
repeat | Repeat a string a specified number of times |
replace | Replace occurrences of a specified string or regular expression with a replacement string |
search | Search for a specific string or regular expression |
slice | Extract a substring from a string |
small | Create the HTML <small> element |
split | Split a string into an array of strings using delimiter |
startsWith | Determine whether a string starts with a specific substring |
strike | Create the HTML <strike> element |
sub | Create the HTML <sub> element |
substr | Extract a substring from a string given a start position and a length |
substring | Extract a substring from a string given a start and end position |
sup | Create the HTML <sup> element |
toLocaleLowerCase | Convert a string to lowercase based on a locale |
toLocaleUpperCase | Convert a string to uppercase based on a locale |
toLowerCase | Convert a string to lowercase |
toString | Return a string representation of an object |
toUpperCase | Convert a string to uppercase |
trim | Remove whitespace characters from start and end of string |
trimEnd | Remove whitespace characters from end of string |
trimStart | Remove whitespace characters from start of string |
valueOf | Return the primitive value of a string object |
JavaScript Number Methods
EPSILON | Return the smallest positive number approaching zero |
isFinite | Return a Boolean value indicating whether a value is a finite number |
isInteger | Return a Boolean value indicating whether a value is an integer |
isNaN | Return a Boolean value indicating whether a value is of type Number with a value of NaN |
isSafeInteger | Return a Boolean value indicating whether a value is a safe integer |
MAX_SAFE_INTEGER | Return the maximum safe integer value |
MAX_VALUE | Return the maximum numeric value |
MIN_SAFE_INTEGER | Return the minimum safe integer value |
MIN_VALUE | Return the smallest positive numeric value |
NaN | Return the value that represents Not-A-Number |
NEGATIVE_INFINITY | Return the value that represents negative infinity |
parseFloat | Parse a string and return a floating point number |
parseInt | Parse a string and return an integer number |
POSITIVE_INFINITY | Return the value that represents positive infinity |
toExponential | Convert a number to exponential notation |
toFixed | Convert a number to fixed-point notation |
toLocaleString | Convert a number to a locale-specific numeric representation |
toPrecision | Convert a number to a specific precision |
toString | Convert a number to a string |
valueOf | Return the primitive value of a Number object |
JavaScript Math Functions
abs | Return the absolute value of a number |
acos | Calculate the arc cosine of a number |
acosh | Calculate the hyperbolic arc cosine of a number |
asin | Calculate the arc sine of a number |
asinh | Calculate the hyperbolic arc sine of a number |
atan | Calculate the arc tangent of a number |
atan2 | Calculate the arc tangent of (x,y) coordinates |
atanh | Calculate the hyperbolic arc tangent of a number |
cbrt | Calculate the cube root of a number |
ceil | Round a number up and return an integer value |
clz32 | Count the number of leading zeros in a number represented as 32-bit binary |
cos | Calculate the cosine of a number |
cosh | Calculate the hyperbolic cosine of a number |
E | Return the value of the mathematical constant e |
exp | Return e raised to the power of number (enumber) |
expm1 | Return e raised to the power of number minus 1 (enumber - 1) |
floor | Round a number down and return an integer value |
fround | Round a number to a 32-bit single precision float |
hypot | Return the square root of the sum of squares of the parameters provided |
imul | Return the 32-bit integer multiplication of two numbers |
LN10 | Return the natural logarithm of 10 |
LN2 | Return the natural logarithm of 2 |
log | Return the natural logarithm of a number |
log10 | Return the base-10 logarithm of a number |
LOG10E | Return the value of log10e |
log1p | Return the natural logarithm of a number + 1 |
log2 | Return the base-2 logarithm of a number |
LOG2E | Return the value of log2e |
max | Return the largest value from the numbers provided |
min | Return the smallest value from the numbers provided |
PI | Return the value of the mathematical constant π (pi) |
pow | Return m raised to the nth power |
random | Return a random number |
round | Return number rounded to the nearest integer |
sign | Return a value indicating the sign of a number |
sin | Return the sine of a number |
sinh | Return the hyperbolic sine of a number |
sqrt | Return the square root of a number |
SQRT1_2 | Return the square root of 1/2 |
SQRT2 | Return the square root of 2 |
tan | Return the tangent of a number |
tanh | Return the hyperbolic tangent of a number |
trunc | Return the integer portion of a number |
JavaScript Array Methods
concat | Concatenate two or more arrays into a new array |
copyWithin | Copy a portion of an array from one location in the array to another location |
entries | Return a new Array iterator object |
every | Return a Boolean value indicating whether every element satisfies a criteria |
fill | Fill elements of an array with a specified value |
filter | Return a new array with only the elements that satisfy a crtieria |
Advertisements