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
interface X { | |
c: string; | |
d: string; | |
} | |
interface Y { | |
c: number; | |
e: string | |
} |
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
interface D { d: boolean; } | |
interface E { e: string; } | |
interface F { f: number; } | |
interface A { x: D; } | |
interface B { x: E; } | |
interface C { x: F; } | |
type ABC = A & B & C; |
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
interface D { d: boolean; } | |
interface E { e: string; } | |
interface F { f: number; } | |
interface A { x: D; } | |
interface B { x: E; } | |
interface C { x: F; |
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
function makeIterator(array) { | |
let index = 0; | |
return { | |
next: function () { | |
if (index < array.length) { | |
return { value: array[index++], done: false }; | |
} else { | |
return { done: true }; | |
} |
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
let numbers = [1, 2, 3]; | |
let it = numbers[Symbol.iterator](); | |
console.log(it.next()); // {value: 1, done: false} | |
console.log(it.next()); // {value: 2, done: false} | |
console.log(it.next()); // {value: 3, done: false} | |
console.log(it.next()); // {value: undefined, done: true} | |
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
function doSomething(a, b, c) { | |
for(let arg of arguments) { | |
console.log(arg); | |
} | |
} | |
doSomething(13, 15, 17); |
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
function doSomething(a, b, c) { | |
let it = arguments[Symbol.iterator](); | |
console.log(it.next()); // {value: 13, done: false} | |
console.log(it.next()); // {value: 15, done: false} | |
console.log(it.next()); // {value: 17, done: false} | |
console.log(it.next()); // {value: undefined, done: true} | |
} | |
doSomething(13, 15, 17); |
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
let someText = 'code'; | |
let iterator = someText[Symbol.iterator](); | |
console.log(iterator.next()); // { value: "c", done: false } | |
console.log(iterator.next()); // { value: "o", done: false } | |
console.log(iterator.next()); // { value: "d", done: false } | |
console.log(iterator.next()); // { value: "e", done: false } | |
console.log(iterator.next()); // { value: undefined, done: true } |
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
interface IteratorResult<T> { | |
done: boolean; | |
value: T; | |
} | |
interface Iterator<T> { | |
next(value?: any): IteratorResult<T>; | |
} | |
interface Iterable<T> { |
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
interface IteratorResult<T> { | |
done: boolean; | |
value: T; | |
} | |
interface Iterator<T> { | |
next(value?: any): IteratorResult<T>; | |
} | |
interface Iterable<T> { |