Learn JavaScript - Introduction Cheatsheet - Codecademy
Learn JavaScript - Introduction Cheatsheet - Codecademy
Introduction
console.log()
JavaScript
Methods
Methods return information about an object, and // Returns a number between 0 and 1
are called by appending an instance with a period
Math.random();
. , the method name, and parentheses.
https://www.codecademy.com/learn/introduction-to-javascript/modules/learn-javascript-introduction/cheatsheet 12/6/23, 11 42 AM
Page 1 of 9
:
Built-in Objects
Numbers
String .length
The .length property of a string returns the let message = 'good nite';
number of characters that make up the string.
console.log(message.length);
// Prints: 9
console.log('howdy'.length);
// Prints: 5
Data Instances
https://www.codecademy.com/learn/introduction-to-javascript/modules/learn-javascript-introduction/cheatsheet 12/6/23, 11 42 AM
Page 2 of 9
:
Booleans
Booleans are a primitive data type. They can be let lateToWork = true;
either true or false .
Math.random()
Math.floor()
In JavaScript, single-line comments are created // This line will denote a comment
with two consecutive forward slashes // .
Null
https://www.codecademy.com/learn/introduction-to-javascript/modules/learn-javascript-introduction/cheatsheet 12/6/23, 11 42 AM
Page 3 of 9
:
Strings
Strings are a primitive data type. They are any let single = 'Wheres my bandit hat?';
grouping of characters (letters, spaces, numbers,
let double = "Wheres my bandit hat?";
or symbols) surrounded by single quotes ' or
double quotes " .
Arithmetic Operators
Multi-line Comments
let baseUrl =
'localhost/taxwebapp/country';
https://www.codecademy.com/learn/introduction-to-javascript/modules/learn-javascript-introduction/cheatsheet 12/6/23, 11 42 AM
Page 4 of 9
:
Remainder / Modulo Operator
Assignment Operators
console.log(number);
// Prints: 120
https://www.codecademy.com/learn/introduction-to-javascript/modules/learn-javascript-introduction/cheatsheet 12/6/23, 11 42 AM
Page 5 of 9
:
String Interpolation
// String interpolation
`Tommy is ${age} years old.`;
Variables
Unde!ned
https://www.codecademy.com/learn/introduction-to-javascript/modules/learn-javascript-introduction/cheatsheet 12/6/23, 11 42 AM
Page 6 of 9
:
Learn Javascript: Variables
Declaring Variables
Template Literals
Template literals are strings that allow embedded let name = "Codecademy";
expressions, ${expression} . While regular
console.log(`Hello, ${name}`);
strings use single ' or double " quotes,
template literals use backticks instead. // Prints: Hello, Codecademy
https://www.codecademy.com/learn/introduction-to-javascript/modules/learn-javascript-introduction/cheatsheet 12/6/23, 11 42 AM
Page 7 of 9
:
let Keyword
const Keyword
String Concatenation
Print Share
https://www.codecademy.com/learn/introduction-to-javascript/modules/learn-javascript-introduction/cheatsheet 12/6/23, 11 42 AM
Page 8 of 9
:
https://www.codecademy.com/learn/introduction-to-javascript/modules/learn-javascript-introduction/cheatsheet 12/6/23, 11 42 AM
Page 9 of 9
: