Skip to content Skip to sidebar Skip to footer

Performance - String.charat(0) Vs. /^.{1}/

Which should be faster conceptually speaking? String.charAt(0) or /^.{1}/ (regex)

Solution 1:

String.charAt(0), regex have to be processed and applied.

Speed Test Resource:

Paul S. for the comparison test, http://jsperf.com/charat-vs-regex-vs-prop

joseph-the-dreamer for adding more to the test, http://jsperf.com/charat-vs-regex-vs-prop/3

Post a Comment for "Performance - String.charat(0) Vs. /^.{1}/"