ES2015 이상에서는 Error 생성자가 new.target 으로 프로토타입 사슬을 서브클래스로 맞춰 준다. ES5 로 내리면 new.target 이 없어 만들어진 객체의 프로토타입이 Error.prototype 에 머물고, instanceof CustomError 가 false 가 된다. super() 바로 뒤에 Object.setPrototypeOf(this, CustomError.prototype) 로 직접 맞춘다.

-- Error 를 상속한 클래스: 프로토타입 사슬을 누가 맞추나
construct :: Target -> Class -> Object
construct ES2015 cls = Object { proto = prototype cls }      -- Error 가 new.target 으로 맞춘다
construct ES5    _   = Object { proto = prototype Error }    -- new.target 이 없다 → instanceof CustomError == False

-- 고침: super(message) 직후 Object.setPrototypeOf(this, CustomError.prototype) — ES2015+ 타깃이면 필요 없다

출처

`#287`