IMHO this looks like an overkill in JS, can we simply pass strings? It does not look like a big performance improvement (or do you have any measurements?) but rather a significant complication which can be obviated.