DEV Community

loading...

Discussion on: 17 Pro JavaScript tricks you didn't know

Collapse
zoedreams profile image
☮️✝️☪️🕉☸️✡️☯️

1337 chop decimals with bitwise

var f = 3.14159;
var i = f|0
console.log("look ma` no decimal %n", i);
Enter fullscreen mode Exit fullscreen mode

1337 inject args with IoC with literal string reflection using .hasOwnProperty

static inject(clazz) {
    if(!clazz.hasOwnProperty('resource')) {
      throw new Error("All resources of type 'BaseResource' require the static function 'resource'");
    }
    global.talk.express.post(Api.URI[clazz.name], (..._) => clazz.resource(..._));
  }
Enter fullscreen mode Exit fullscreen mode

^github.com/ZoeDreams/talk/blob/mas...