ChrisGaudreau

Joined 12 years ago

Karma
298
Submissions
95
Member since
Mar 21
View on Hacker News

Recent submissions

Comment · 11 years ago
In the context of React, it allows you to implement a `shouldComponentUpdate` method which simply compares the references of two objects, which is extremely fast. If the references remain the same, then there is no need to invoke `render` again.
Comment · 11 years ago
Prototype-type based systems are cool in theory, but aren't much fun to use in practice. They are incredibly powerful and easy to abuse. Basically single inheritance in disguise.

Classes aren't great either, but at least using class inheritance makes you feel icky, you're not likely to have shared state on the prototype being randomly mutated, and it's pretty readable.

Comment · 11 years ago
I think I actually had a similar problem, but using `filter`. Don't really remember though.
Comment · 11 years ago
Comment · 11 years ago
P:
Comment · 11 years ago
I prefer flipped smileys. (:
Comment · 11 years ago
Comment · 11 years ago
Would this technique work to center, say, an <img> tag with undeclared dimensions inside of a div? Or do you have to jump through hoops?
Comment · 11 years ago
An alternative using ES6 object parameters:

  function addObserver(observer, func, { weak = false } = {}) {
    if (weak) {
      // ...
    }
  }

  addObserver(observer, 'load', { weak: true });

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton