Created
July 30, 2017 07:48
-
-
Save szy0syz/c2b907688cd850d412bc53a430f9c6b5 to your computer and use it in GitHub Desktop.
JavaScript String extension
This file contains 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
String.prototype.queryURLParams = function () { | |
let obj = {}, | |
reg = /([^?=&#]+)=([^?=&#]+)/g; | |
this.replace(reg, function () { | |
// arguments[0] === this | |
const key = arguments[1]; | |
obj[key] = arguments[2]; | |
}); | |
return obj; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment