Skip to content

Instantly share code, notes, and snippets.

@Mouvedia
Mouvedia / trim
Last active September 13, 2015 22:40
//http://perfectionkills.com/whitespace-deviations/
//https://web.archive.org/web/20150905201345/http://www.merlyn.demon.co.uk/js-valid.htm#RsT
''.trim||(String.prototype.trim=function(){return this.replace(/^\s+|\s+$/g, '')})
/*
dependencies
isArray
defineProperties
TODO
defineProperties > defineProperty
http://stackoverflow.com/a/17935125/248058
isString
clear
typeof this.className === 'object' ? this.setAttribute('class', '') : this.className = '';