Last active
September 23, 2017 13:35
-
-
Save wcoder/f1cba160411340654a1b520da417fffb to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// (c) 2016 Yauheni Pakala | |
var _parseInt = str => str.replace(/(.*?)(\d+)(.*)/,'$2') - 0; | |
// test | |
console.log(_parseInt("123hui")); | |
console.log(_parseInt("123hui321")); | |
console.log(_parseInt("hui123")); | |
// time | |
console.time("parseInt"); | |
parseInt("123qwe"); | |
console.timeEnd("parseInt"); | |
console.time("_parseInt"); | |
_parseInt("123qwe"); | |
console.timeEnd("_parseInt"); | |
// result: | |
// parseInt: 0.005126953125ms | |
//_parseInt: 0.00390625ms |
Author
wcoder
commented
Sep 23, 2017
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment