3 ms·
It only throws if you access the property with the [] or . syntax, so I don't think this particular thing is a big problem.
by i_s 12y ago
It only throws if you access the property with the [] or . syntax, so I don't think this particular thing is a big problem.
- EdwardDiego 12y agoWhat other syntax is there to access a property?
- ianbicking 12y agoThey only barely mention it, but I think they expect you do to `foo = 'foo' in obj ? obj.foo : undefined` instead of `foo = obj.foo`
- jahewson 12y agoI really doubt it, as that's an unsound bypassing of the type system. Missing properties are slow in JavaScript, because the in-memory representation of the class has to be modified when new properties are added. Given that strong mode is about performance, it would make far more sense to just prohibit missing properties and encourage use of other ES6 language mechanisms such default parameters instead.
- deleted 12y ago[deleted]
- i_s 12y agoYou check if is there before you access it with . or [].
- EdwardDiego 12y agoOh right. I love those null/undefined checking chains, it really puts the Java in JavaScript.