Skip to content

Instantly share code, notes, and snippets.

View kutyel's full-sized avatar
🌊
数学者に俺は成る!

Flavio Corpa kutyel

🌊
数学者に俺は成る!
View GitHub Profile
// underscore
_.pluck(dc, 'name')
// nativo
dc.map(x => x.name)
// output
// > ["batman", "superman", "greenarrow", "greenlantern"]
// underscore
_.where(dc, { power: 70 })
// nativo
dc.filter(x => x.power === 70)
// output
// > [
// > Object { name: "greenarrow", power: 70 },
// > Object { name: "greenlantern", power: 70 }
// > ]
// undercore
_.findWhere(dc, { power: 90 })
// nativo
dc.find(x => x.power === 90)
// output
// > Object { name: "superman", power: 90 }
// underscore
_.contains([1, 2, 3], 3)
// nativo
[1, 2, 3].includes(3)
// output
// > true
// underscore
_.max(dc, 'power') // quién será el héroe más poderoso?
// nativo
dc.reduce((x, y) => x.power > y.power ? x : y)
// output
// > Object { name: "batman", power: 100 }
// Lo siento Superman, Batman siempre gana!
// underscore
_.min(dc, 'power') // y el más flojo?
// underscore
_.chain(dc).pluck('name').contains('greenarrow').value()
// nativo
dc.map(x => x.name).includes('greenarrow')
// output
// > true
@kutyel
kutyel / bling.js
Created August 16, 2017 07:20 — forked from paulirish/bling.js
bling dot js
/* bling.js */
window.$ = document.querySelectorAll.bind(document);
Node.prototype.on = window.on = function (name, fn) {
this.addEventListener(name, fn);
}
NodeList.prototype.__proto__ = Array.prototype;
@kutyel
kutyel / amazon.task1.js
Last active August 28, 2017 12:49
My Interview with Amazon Scotland 💯
/*
* Task 1
* Visible nodes in a node subtree
*/
const solution = T => visibles(T, -100000)
const visibles = (T, max) => {
if (T === null) return 0
let num = 0
@kutyel
kutyel / includes.js
Created September 5, 2017 10:27
ES7 Array.prototype.includes() and String.prototype.includes()
// Array.prototype.includes()
[1, 2, 3].includes(2) // > true
[1, 2, 3].includes(4) // > false
// String.prototype.includes()
const str = 'Los gatos son seres superiores'
str.includes('gato') // > true
str.includes('perro') // > false
@kutyel
kutyel / exponentiation_operator.js
Created September 5, 2017 10:30
ES7 Exponentiation Operator
7 ** 2 === Math.pow(7, 2) // > true
7 ** 3 === Math.pow(7, 3) // > true
2 ** 10 === Math.pow(2, 10) // > true