티스토리 뷰
Regular Expression Based Implementation
String.prototype.replaceAll = function(search, replacement) { var target = this; return target.replace(new RegExp(search, 'g'), replacement); };
Split and Join (Functional) Implementation
String.prototype.replaceAll = function(search, replacement) { var target = this; return target.split(search).join(replacement); };
The regular expression based implementation is the fastest, with the split and join implementation being 53% slower.
출처 : Stackoverflow'코딩방 > 라이브러리, 플러그인' 카테고리의 다른 글
[JS] 코드 문법 강조 플러그인 (Syntax Highlighter Plugins) (0) | 2017.11.01 |
---|---|
[JS] 로딩중 관련 JS 라이브러리 3가지 (0) | 2017.10.31 |
댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday