code: function getLuminance(c) {
      let i, x;
      const a = []; // so we don't mutate
      for (i = 0; i < c.length; i++) {
          x = c[i] / 255;
          a[i] = x <= 0.03928 ? x / 12.92 : Math.pow((x + 0.055) / 1.055, 2.4);
      }
      return 0.2126 * a[0] + 0.7152 * a[1] + 0.0722 * a[2];
  }
docs: http://stackoverflow.com/a/3943023/112731