Skip to content

Instantly share code, notes, and snippets.

var _ = require("lodash");
var performRoles = require("./performRoles.js");
performRoles({ foo: 1 });
@panuhorsmalahti
panuhorsmalahti / squeeze.js
Created May 20, 2015 17:48
Simple way to combine multiple elements in an array.
Array.prototype.squeeze = function (n, fn) {
const from = Object(this).slice();
const to = [];
while (n > 0 && from.length)
to.push(fn.apply(undefined, from.splice(0, n)));
return to;
}
@panuhorsmalahti
panuhorsmalahti / gist:b91b41d6802f63a2c346
Created November 4, 2014 20:40
JavaScript signed zero example
// JavaScript signed zero example.
// Note that +0 equals -0 in JavaScript.
var getPlusZero = () => +0;
var getNegativeZero = () => -0;
var isPlusZero = x => Math.atan2(0, x) === 0;
var isNegativeZero = x => Math.atan2(0, x) !== 0;
console.log(isPlusZero(getPlusZero()));
console.log(isPlusZero(getNegativeZero()));