Created
December 25, 2011 22:05
-
-
Save 0i0/1519811 to your computer and use it in GitHub Desktop.
javascript snippets
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
function getCookie(key){ | |
var regEx = new RegExp(key+"=([^;]*)","g"); | |
return regEx.exec(document.cookie)[1] | |
} | |
String.prototype.format = function () { | |
var args = arguments; | |
return this.replace(/\{\{|\}\}|\{(\d+)\}/g, function (curlyBrack, index) { | |
return ((curlyBrack == "{{") ? "{" : ((curlyBrack == "}}") ? "}" : args[index])); | |
}); | |
}; | |
"{0}{1}".format("{1}", "{0}") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment