ARRAY
declare array
let todoList = [];
function rememberTo(task) {
todoList.push(task);
}
function whatIsNext() {
return todoList.shift();
}
function urgentlyRememberTo(task) {
todoList.unshift(task);
}
console.log([1, 2, 3, 2, 1].indexOf(2));
// → 1
console.log([1, 2, 3, 2, 1].lastIndexOf(2));
// → 3
console.log([0, 1, 2, 3, 4].slice(2, 4));
// → [2, 3]
console.log([0, 1, 2, 3, 4].slice(2));
// → [2, 3, 4]
add elements in slice
console.log(["hello", "bro"].join(" "));
// -> hello bro
[1].concat([2])
// [1, 2]
STRINGS
strings are constants
console.log("раз два три".indexOf("ва"));
// -> 5
console.log(" ладно \n ".trim());
// → ладно