Hacker News
new
|
past
|
comments
|
ask
|
show
|
jobs
|
submit
login
reverius42
on April 15, 2015
|
parent
|
context
|
favorite
| on:
Introducing T3: Enabling Large Scale JavaScript Ap...
I don't see how static analysis helps the switch-case on strings. It might, if JS had a more expressive (static) type system. An enum type, perhaps?
glibgil
on April 15, 2015
|
next
[–]
If you have static analysis then it makes sense to use types instead of strings. If you don't have static analysis then there isn't much motivation which is why you see strings everywhere in unanalyzed JavaScript.
gnud
on April 15, 2015
|
prev
[–]
I usually do something like
var Constants = { valueA: function valueA() {}, valueB: function valueB() {} };
Mister_Snuggles
on April 15, 2015
|
parent
|
next
[–]
Why do you use empty functions instead of a number or a string?
madeofpalk
on April 16, 2015
|
root
|
parent
|
next
[–]
My guess is than a function will always be a unique object, rather than if it was a number or string, there's a chance you use the same value twice.
gingerrr
on April 16, 2015
|
root
|
parent
|
next
[–]
an object literal would provide the same guarantee but without the overhead of function prototype methods, wonder if there's any other reason?
drifkin
on April 16, 2015
|
root
|
parent
|
next
[–]
Maybe they're using functions so the values can have names? Perhaps easier to debug.
anewhnaccount
on April 16, 2015
|
parent
|
prev
[–]
In ES6 you can use Symbol.
Guidelines
|
FAQ
|
Lists
|
API
|
Security
|
Legal
|
Apply to YC
|
Contact
Search: