1、javascript中构造equals()、trim()方法并应用
1 String.prototype.Trim = function() 2 { 3 return this.replace(/(^\s*)|(\s*$)/g, ""); 4 } 5 String.prototype.equals = function(s){ 6 return this == s; 7 } 8 var tip = ‘${tip }‘; 9 tip.Trim(); 10 if(!tip.equals("${tip }")){ 11 if(tip.length != 0){ 12 if(tip != null){ 13 alert(tip); 14 } 15 } 16 }