/ Published in: JavaScript

Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
function typeOf(value) { var s = typeof value; if (s === 'object') { if (value) { if (value instanceof Array) { s = 'array'; } } else { s = 'null'; } } return s; } String.prototype.supplant = function (o) { return this.replace(/{([^{}]*)}/g, function (a, b) { var r = o[b]; return typeof r === 'string' || typeof r === 'number' ? r : a; } ); }; String.prototype.trim = function () { return this.replace(/^\s+|\s+$/g, ""); };
URL: http://javascript.crockford.com/remedial.html
Comments
