let buffer = new ArrayBuffer(1024);
console.log(buffer.byteLength);
let salaries = Array.of(9000);
console.log(salaries);
const amounts = [800, 810, 820]
salaries = Array.from(amounts, v => v + 100);
console.log(salaries);
// Start filling in pos 1 and 2 pos to stop at
salaries.fill(900, 1, 2);
console.log(salaries);
salaries = amounts
let result = salaries.find(value => value >= 750);
console.log(result); // returns first value found in the criteria
salaries = amounts
salaries.copyWithin(2, 0); // 2 = where to copy, 0 = item to copy
console.log(salaries);
let ids = ['A', 'B', 'C'];
// Prints out [ 0, 'A' ] [ 1, 'B' ] [ 2, 'C' ]
console.log(...ids.entries());
console.log(...ids.keys()); // Logs out 0 1 2
console.log(...ids.values()); // Logs out A B C
let employee1 = { name: 'Jake' };
let employee2 = { name: 'Chris' };
let employees = new Map();
employees.set(employee1, 'ABC');
employees.set(employee2, '123');
console.log(employees.get(employee1));
console.log(employees.size); // Logs out 2
employees.delete(employee2);
console.log(employees.size); // Logs out 1
employees.clear();
console.log(employees.size); // Logs out 0
let arr = [
[employee1, 'ABC'],
[employee2, '123']
];
employees = new Map(arr);
console.log(employees.size); // Logs out 2
console.log(employees.has(employee2)); // Logs out True
let list = [...employees.values()];
console.log(list); // [ 'ABC', '123' ]
list = [...employees.entries()];
console.log(list); // [ [ { name: 'Jake' }, 'ABC' ], [ { name: 'Chris' }, '123' ] ]
console.log(list[0][1]); // ABC
let s = '8000';
console.log(isFinite(s));
let sum = 408.2;
console.log(Number.isInteger(sum));
let a = {
x: 1
};
let b = {
x: 3,
y: 2
};
let c = {
z: 1
};
Object.setPrototypeOf(a, b);
Object.setPrototypeOf(b, c);
console.log(a.y); // Logs out 2
let target = {};
Object.assign(target, a, b); // Doesn't take properties set in setPrototypeOf
console.log(target); // logs out { x: 3, y: 2 }
let amount = NaN;
console.log(Object.is(amount, amount)); // fixes the === bug
let perks = new Set();
perks.add('Car');
perks.add('Vacation');
perks.add('Car');
perks.add('Jet');
// prints 2 because all of the items of the set have to be unique
console.log(perks.size);
console.log(perks.has('Jet')); // true
console.log(perks.has('Cool Hat')); // false
console.log(...perks.keys()); // Car Vacation Jet
console.log(...perks.values()); // Car Vacation Jet
console.log(...perks.entries()); // [ 'Car', 'Car' ] [ 'Vacation', 'Vacation' ] [ 'Jet', 'Jet' ]
perks = new Set([
{id: 1},
{id: 1}
]);
// 2 because object literals are unique
console.log(perks.size);
let title = 'Santa Barbara Surf Riders';
// Check if strings starts with substring
console.log(title.startsWith('Santa'));
// Check if strings ends with substring
console.log(title.endsWith('Santa'));
// Check if strings includes substring
console.log(title.includes('Surf'));
var title_with_emoji = "Surfer Emoji: \u{1f3c4}";
console.log(title_with_emoji);
// Prints out real length
console.log(title_with_emoji.normalize().length);
// Repeat String
console.log(title_with_emoji.repeat(3));