Coggle requires JavaScript to display documents.
console.time("Hello");
console.timeEnd("Hello");
console.error("This is some error");
console.clear();
console.warn("This is a warning");
console.log('hello');
console.table({ a: 1, b: 2 });
concat()
val = firstName.concat(" ", lastName);
toUpperCase(), toLowerCase()
val = firstName.toUpperCase();
val = firstName.toLowerCase();
indexOf(), lastIndexOf()
val = firstName.indexOf("a");
charAt()
val = firstName.charAt("2");
val = firstName.charAt(firstName.length - 1);
substring()
val = firstName.substring(0, 4);
slice()
val = firstName.slice(0, 4);
val = firstName.slice(-3);
split()
val = str.split(" ");
val = tags.split(",");
replace()
val = str.replace("Brad", "Jack");
include()
val = str.includes("foo");
... <html> ...
${ ... }
html = ` <ul> <li>Name: ${firstName}</li> <li>Age: ${age}</li> <li>Job: ${job}</li> <li>City: ${city}</li> <li>${2 + 2}</li> <li>${hello()}</li> <li>${age > 30 ? "Over 30" : "Under 30"}</li> </ul> document.body.innerHTML = html; `;
val = 'That\'s awesome, I can\'t wait';
val = firstName + " " + lastName;
val = "Brad "; val += "Traversy";
val = firstName.length;
val = firstName[2];
const cars = [ ... ];
for (let index = 0; index < cars.length; index++) { cars[index] }
cars.forEach( function (car, index, array) { ... } )
console.log(
);
const arr2 = arr1.map(function(iterator) { ... })
const ids = users.map(function (user) { return user.id }
for (let index = 0; index < array.length; index++) { ... }
while (condition) { ... index++ }
do { ... index ++} while (condition);
for (let key in object) { ... }
object(x) = value;
for (let x in user) { ... }
${x} : ${user[x]}
var fullName = "John Doe";
String()
.toString()
val = String(555);
val = String(true);
val = true.toString();
val = Number("5");
val = Number([1, 2, 3]);
NaN
parseInt()
parseFloat()
String(5) + 6
id < 100
id > 100
id >= 100
id <= 100
if(something) { ... } else { ... }
if (something) { ... } elseif { ... } else { ... }
console.log(id === 100 ? "CORRECT" : "INCORRECT");
if (id === 100) console.log("CORRECT"); else console.log("INCORRECT");
switch (color) { ... }
case 'red' : console.log('color is red'); break;
case 'blue' : console.log('color is blue'); break;
default: console.log('color is shat'); break;
switch(new Date().getDay()) { ... }
Today is ${day}
case 0: day = 'Sunday';
if (typeof id !== "undefined") { ... }
if(age > 0 && age < 12){ ... }
if(age < 16 || age > 65){ ... }
function greet() { ... function scope }
call function : greet():
function greet() { ... return val }
function greet(firstName) { ... }
function greet(firstName, lastName) { ... }
greet()
→ undefined
function greet(firstName = "John", lastName = "Doe") { ... }
(function () { ... } ();
(function (cheese) { ... } ();
const square = function (x = 3) { ... }
const todo = { ... }
add: function() { ... },
edit: function(id) { ... },
array.isArray()
val = numbers.indexOf(36);
array.indexOf()
array.push()
numbers.push(250);
array.unshift()
numbers.unshift(120);
array.shift()
numbers.shift();
array.reverse()
array.splice()
numbers.splice(1, 1);
numbers.splice(2, 2, 11, 12);
arr3 = arr1.concat(ar2);
val = numbers.concat(numbers2);
numbers.pop();
arr.sort ()
val = fruit.sort();
arr.sort()
val = numbers.sort((x, y) => x - y);
val = numbers.find((num) => num > 50);
const numbers = [ ... ]
const numbers = new Array( ... )
const mixed = [22, "Hello", true, undefined, null, { a: 1, b: 1 }, new Date()];
val = numbers[3];
numbers[2] = 100;
{ firstName : "Steve" }
val = person.firstName
getBirthYear = function () { ... }
const person = { ... }
const people = [ ... ]
getMonth()
getDate()
getDay()
getFullYear()
getHours()
getMinutes()
getMilliseconds()
getTime()
setMonth()
setDate()
setFullYear()1
setFullYear()
setHours()
setMinutes()
const today = new Date();
typeof() → object
let birthday = new Date("9-10-1981");
let birthday = new Date("9-10-1981 11:25:00");
birthday = new Date("September 10 1981");
birthday = new Date("9/10/1981");
Math.round()
Math.ceil()
Math.floor()
Math.sqrt()
Math.abs()
Math.pow()
Math.min(). Math.max()
Math.random()