Security is Everyone's Job
Array: let arr = [1, 2, 3];
let arr = [1, 2, 3];
Add Number to List: arr.push(4);
arr.push(4);
Take Off Last Number: arr.pop();
arr.pop();
Joins & Returns String: arr.join("-");
arr.join("-");
Declare Stringlet str = "Hello world";
let str = "Hello world";
Uppercase: str.toUpperCase();
str.toUpperCase();
Lowercase: str.toLowerCase();
str.toLowerCase();
Replace: str.replace("world", "Bing");
str.replace("world", "Bing");
Splits: str.split(" ");
str.split(" ");
Declare Number: let num = 42;
let num = 42;
Square Root: Math.sqrt(num);
Math.sqrt(num);
Round to Nearest Int: Math.round(num);
Math.round(num);
Less or Equal to Int: Math.floor(num);
Math.floor(num);
Greater or Equal to Int: Math.ceil(num);
Math.ceil(num);
Create Function:
function name(parameter1, parameter2) {return value;}
{return value;}
Calling Function: name(argument1, argument2);
name(argument1, argument2);
For Loop:
for (let i = 0; i < 10; i++) {
}
While Loop:
while (condition) {
If/Else Loop:
if (condition) {
} else if (anotherCondition) {
} else {
Returns Element by ID: document.getElementById(id);
document.getElementById(id);
Returns Class: document.getElementsByClassName(name);
document.getElementsByClassName(name);
Returns Selector: document.querySelector(selector);
document.querySelector(selector);
Returns All Selector: document.querySelectorAll(selector);
document.querySelectorAll(selector);
Get/Set HTML Element: element.innerHTML;
element.innerHTML;
Get/Set CSS Element: element.style.property;
element.style.property;
Set Value: element.setAttribute(name, value);
element.setAttribute(name, value);
Get Value: element.getAttribute(name);
element.getAttribute(name);
Add Event Handler: element.addEventListener(event, function);
element.addEventListener(event, function);
Remove Event Handler: element.removeEventListener(event, function);
element.removeEventListener(event, function);
Execute Function on Load: window.onload = function;
window.onload = function;
Return/Set URL: window.location.href;
window.location.href;
Alert Message: window.alert(message);
window.alert(message);
Confirm Box: window.confirm(message);
window.confirm(message);
Prompt Box: window.prompt(message, default);
window.prompt(message, default);