Skip to content

Instantly share code, notes, and snippets.

View bbaaxx's full-sized avatar
🍊
Pasele a lo barrido

Ed Mosqueda bbaaxx

🍊
Pasele a lo barrido
View GitHub Profile
@bbaaxx
bbaaxx / IIG-ES6-08.js
Created November 15, 2017 18:45
Code for blog post about iterators iterables and generators with ES6
console.log(Array.from(someObject)) // [1, "Yolodog", "a"]
// con spread operator:
console.log([...someObject]) // [1, "Yolodog", "a"]
console.log(...someObject) // 1 "Yolodog" "a"
@bbaaxx
bbaaxx / IIG-ES6-07.js
Created November 15, 2017 18:43
Code for blog post about iterators iterables and generators with ES6
const someObject = {
a: 1,
perrito: 'Yolodog',
aChar: 'a',
}
someObject[Symbol.iterator] = function() {
let currentKey = 0;
const keys = Object.keys(this);
const { length } = keys;
@bbaaxx
bbaaxx / IIG-ES6-06.js
Created November 15, 2017 18:42
Code for blog post about iterators iterables and generators with ES6
function makeIterator(array) {
let nextIndex = 0;
return {
next: function() {
return nextIndex < array.length ?
{value: array[nextIndex++], done: false} :
{done: true};
}
};
}
@bbaaxx
bbaaxx / IIG-ES6-05.js
Last active November 18, 2017 23:09
Code for blog post about iterators iterables and generators with ES6
const someArray = [2, 4, 8];
for (let n of someArray) { console.log(n); }
// 2
// 4
// 8
@bbaaxx
bbaaxx / IIG-ES6-04.js
Created November 15, 2017 18:40
Code for blog post about iterators iterables and generators with ES6
for (let char of 'yo!') { console.log(char); }
// y
// o
// !
@bbaaxx
bbaaxx / IIG-ES6-03.js
Last active November 18, 2017 23:08
Code for blog post about iterators iterables and generators with ES6
const someArray = [2, 4, 8];
let someArraySquared = [];
for (let n of someArray) {
someArraySquared.push(n * n);
}
console.log(someArray, someArraySquared);
@bbaaxx
bbaaxx / IIG-ES6-02.js
Last active November 18, 2017 23:08
Code for blog post about iterators iterables and generators with ES6
const someArray = [2, 4, 8];
let someArraySquared = someArray.map(x => x * x);
console.log(someArray, someArraySquared); // [2, 4, 8], [4, 16, 64]
@bbaaxx
bbaaxx / IIG-ES6-01.js
Last active November 15, 2017 18:48
Code for blog post about iterators iterables and generators with ES6
const someArray = [2, 4, 8];
let someArraySquared = [];
for (let i = 0; i < someArray.length; i += 1) {
someArraySquared.push(someArray[i] * someArray[i]);
}
console.log(someArray, someArraySquared); // [2, 4, 8], [4, 16, 64]
@bbaaxx
bbaaxx / wtf.js
Created November 7, 2017 08:01 — forked from MichalZalecki/wtf.js
/* VT100 terminal reset (<ESC>c) */
console.log('\033c');
/* numbers comparations */
> '2' == 2
true
> '2' === 2
var html = (function () {/*
<!DOCTYPE html>
<html>
<body>
<h1>Hello, world!</h1>
</body>
</html>
*/}).toString().match(/[^]*\/\*([^]*)\*\/\}$/)[1];