我们再来聊聊Function.apply()在提升程序性能方面的技巧。我们先从Math.max()函数说起, Math.max后面可以接任意个参数,最后返回所有参数中的最大值。比如 alert(Math.max(5,8)) //8alert(Math.max(5,7,9,3,1,6)) //9但是在很多情况下,我们需要找出数组中最大的元素。vararr=[5,7,9,1]alert(Math.max(arr)) // 这样却是不行的。一定要这样写functiongetMax(...
http://www.jb51.net//article/5015.htm
关于对象的继承,一般的做法是用复制法: Object.extend见protpotype.js 的实现方法:[code]Object.extend = function(destination, source) { for (property in source) { destination[property] = source[property]; ...
http://www.jb51.net//article/5014.htm
共有:2/10,当前1/1页
[首页] [上一页]
1
[下一页] [尾页]
转到:
