3 ms·
What other syntax is there to access a property?
by EdwardDiego 12y ago
What 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.