|
|
|
|
|
by earenndil
3083 days ago
|
|
Probably using a lookup table using the type as an index. I'm not very familiar with javascript, but if types are first-class objects, then you can use the type directly to index into an object (I think that's what classes and hashmaps are called in js?). If not then you'll have to turn the type into a number somehow. Having done that, you'll index it into an array of functions which run the appropriate stringification on the given object. |
|