Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
从概念上讲,哪个应该更快?
String.charAt(0)或/^.{1}/(正则表达式)
String.charAt(0)
/^.{1}/
String.charAt(0), 正则表达式必须被处理和应用。
速度测试资源:
Paul S.对于比较测试,http://jsperf.com/charat-vs-regex-vs-prop joseph-the-dreamer为测试添加更多内容,http://jsperf.com/charat-vs-regex-vs-prop/3
Paul S.对于比较测试,http://jsperf.com/charat-vs-regex-vs-prop
Paul S.
joseph-the-dreamer为测试添加更多内容,http://jsperf.com/charat-vs-regex-vs-prop/3
joseph-the-dreamer