JS设计模式源代码
源代码在线查看: 5.04 - private methods with underscores.js
/* DataParser singleton, converts character delimited strings into arrays. */ GiantCorp.DataParser = { // Private methods. _stripWhitespace: function(str) { return str.replace(/\s+/, ''); }, _stringSplit: function(str, delimiter) { return str.split(delimiter); }, // Public method. stringToArray: function(str, delimiter, stripWS) { if(stripWS) { str = this._stripWhitespace(str); } var outputArray = this._stringSplit(str, delimiter); return outputArray; } };