引数にオブジェクト(ハッシュ)を想定していて、想定していない型の値を渡してもエラーが投げられないこともある。
function F (opt) { this.a = opt.a } function test (opt) { try { console.log(new F(opt)) } catch (err) { return console.error(err) } } test() // [TypeError: Cannot read property 'a' of undefined] test(null) // [TypeError: Cannot read property 'a' of null] test('foo') // {a: undefined} test(1) // {a: undefined} test(function () {}) // {a: undefined} test(false) // {a: undefined} test([]) // {a: undefined} test({a: 'abc'}) // {a: 'abc'}
文字列、数値、boolean、関数 でもエラーを投げないので気が置けない