首页 > 代码库 > I should know the content of js

I should know the content of js

  1. 阻止事件传播,必须显示,return false;

  2. return exp?confirm():!!alert();

  3. js 定时器,线程,启动,开始,停止。参数传递,使用window;

  4. js扩展:

String.prototype.Trim = String.prototype.trim = function() {

return this.replace(/(^\s*)|(\s*$)/g, "");

};


function StringBuffer() {

this._strings_ = new Array();

}


StringBuffer.prototype.append = function(str) {

this._strings_.push(str);

return this;

};

StringBuffer.prototype.toString = function() {

return this._strings_.join("");

};


Date.prototype.toSimpleString = function() {

return (this.getFullYear() - 2000) + "/" + (this.getMonth() + 1) + "/" + this.getDate() + " " + this.getHours() + ":" + this.getMinutes();

};