This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 29: array - `Array.from` static method | |
describe('`Array.from` converts an array-like object or list into an Array', () => { | |
const arrayLike = {0: 'one', 1: 'two', length: 2}; | |
it('call `Array.from` with an array-like object', function() { | |
const arr = Array.from(arrayLike); | |
assert.deepEqual(arr, ['one', 'two']); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 63: String - `includes()` | |
describe('`string.includes()` finds string within another string', function() { | |
describe('find a single character', function() { | |
it('in a three char string', function() { | |
const searchString = 'x'; | |
assert.equal('xyz'.includes(searchString), true); | |
}); | |
it('reports false if character was not found', function() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 34: symbol | |
// A symbol is a unique and immutable data type and may be used as an identifier for object properties | |
// read more at https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol | |
describe('Symbol', function() { | |
it('`Symbol` lives in the global scope', function(){ | |
const expected = Symbol; | |
assert.equal(Symbol, expected); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 47: Set - basics | |
describe('`Set` lets you store unique values of any type', function(){ | |
it('`Set` is a new global constructor function', function() { | |
assert.equal(typeof Set, 'function'); | |
}); | |
it('every value in a set is unique', function() { | |
let set = new Set(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 44: Map - basics | |
describe('`Map` is a key/value map', function(){ | |
it('`Map` is a new global constructor function', function() { | |
assert.equal(typeof Map, 'function'); | |
}); | |
it('provides `new Map().set()` to add key+value pair, `get()` to read it by key', function() { | |
let map = new Map(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 17: unicode - in strings | |
describe('unicode strings', () => { | |
it('are \\u prefixed', () => { | |
const nuclear = `\u2622`; | |
assert.equal(nuclear, '☢'); | |
}); | |
it('value is 4 bytes/digits', () => { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 55: Number - isInteger | |
describe('`Number.isInteger()` determines if a value is an integer', function(){ | |
const isTrue = (what) => assert.equal(what, true); | |
const isFalse = (what) => assert.equal(what, false); | |
it('`isInteger` is a static function on `Number`', function() { | |
const whatType = 'function'; | |
assert.equal(typeof Number.isInteger, whatType); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 54: Object - is | |
describe('`Object.is()` determines whether two values are the same', function(){ | |
describe('scalar values', function() { | |
it('1 is the same as 1', function() { | |
const areSame = Object.is(1, 1); | |
assert.equal(areSame, true); | |
}); | |
it('int 1 is different to string "1"', function() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The iterator protocol defines a standard way to produce a sequence of values (either finite or infinite). | |
// read more at https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | |
// 37: iterator/iterable - array. | |
describe('array is a built-in iterable object', function() { | |
const arr = ['a', 'B', 'see']; | |
describe('the iterator', function() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 22: class - creation | |
describe('class creation', () => { | |
it('is as simple as `class XXX {}`', function() { | |
class TestClass {}; | |
const instance = new TestClass(); | |
assert.equal(typeof instance, 'object'); | |
}); |
NewerOlder