Skip to content

Instantly share code, notes, and snippets.

View SiestaMadokaist's full-sized avatar

Rama Patria Himawan SiestaMadokaist

View GitHub Profile
@0i0
0i0 / gist:1519811
Created December 25, 2011 22:05
javascript snippets
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]));
});