摘要:
1 var proxy = function(func, thisObject) { 2 return (function() { 3 return func.apply(thisObject, arguments); 4 }); 5 }; 6 7 //example 8 var clicky = { 9 wasClicked: function() {},10 addListeners: function() {11 var self = this;12 $('.clicky'... 阅读全文
摘要:
Object.create方法创建一个使用原对象作为其原型的新对象。1 if (typeof Object.create !== 'function') {2 Object.create = function (o) {3 function F() {}4 F.prototype = o;5 return new F();6 };7 }8 newObject = Object.create(oldObject); 阅读全文
摘要:
1 Function.prototype.method = function(name, func) {2 if (!this.prototype[name]) {3 this.prototype[name] = func;4 }5 };具体使用和YUI类似 阅读全文
摘要:
1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 2 <html xmlns="http://www.w3.org/1999/xhtml"> 3 <head> 4 <meta http-equiv="Content-Type" content="text/html;ch 阅读全文
摘要:
zepto This is a headingThis is a paragraph.This is another paragraph.切换段落的 "main" 类 zepto This is a heading Apple IBM Mi... 阅读全文
摘要:
togglevar input = $('input[type=text]'); $('#too_long').toggle(input.val().length < 5); 阅读全文
摘要:
var ss = ['1', '2', '3', '4', '5', '6']; console.log(ss.slice(2,4)); 阅读全文
摘要:
The longest word in the english dictionary is: pneumonoultramicroscopicsilicovolcanoconiosis.把滚动条的水平位置设置为 100px$("button").click(function(){ ... 阅读全文
摘要:
var arr = ['1', '2', '3', '4']; arr.push('qwe'); console.log(arr); 阅读全文
摘要:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/Reducevar ss = [0, 1, 2, 3, 4].reduce(function (previousValue, ... 阅读全文
摘要:
JavaScript中所有变量及函数名会自动提升http://www.cnblogs.com/betarabbit/archive/2012/01/28/2330446.html 阅读全文
摘要:
var a = "http://www.xx.com?id=111&-deb";var b = "http://www.xx.com?-deb&id=111";var d = "http://www.xx.com?-deb&id=111&cc=2";var c = "http://www.xx.co... 阅读全文
摘要:
123456789,4567831匹配前面的4567还有后面的83var r = /\d{3}4567\d{2}[,]\d{4}83\d/; var e = "123456789,4567831"; console.log(r.test(e)); 阅读全文