Comparing various way to check if a string is within the values of a typescript enum (version: 0)
Given this typescript code
// typescript like
enum Status {
A = 'a',
B = 'b',
C = 'c',
D = 'd'
}
what is the faster simpler way to know if a string st is within the enum values.
Comparing performance of: compare individual strings vs use a regex vs use a set
Memory measurements supported only in Chrome.
For precise memory measurements Chrome must be launched with --enable-precise-memory-info flag.
More information: Monitoring JavaScript Memory
Test case name
Result
compare individual strings
use a regex
use a set
Fastest:N/A
Slowest:N/A
ⓘGet performance results from real users on your website with Request Metrics.
Latest run results:
Run details: (Test run date:
2 years ago)
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36