ITeye博客

javascript

共 3 篇文章

javascript进阶1

参考: http://ejohn.org/apps/learn 答案在后面。 1、看下面的例子,能看得出输出什么? var a = 5; function runMe(a){ console.log("a = " + a);//a=? function innerRun(){ console.log("b = " + b);//b=? console.log("c = " + c);//c=? } var b = 7; innerRun(); var c = 8; } runMe(6); for ( var d = 0; d < 3; d++ ) { setTimeout(function(…

2011-12-23 05:10 · javascript

javascript回函数的几种调用方法

先来看下基本的知识,对于一个函数的调用,方法有以下几种。 //下面的几种写法是等价的。 alert('something'); this.alert('something'); alert.call(this,'something'); alert.apply(this,['something']); 以实现数组中each的方法做为例子。 第一种方式: Array.prototype.each = function(callback){ for(var i = 0; i< this.length;i++){ callback(this[i]);//参数既为函数名,直接加括号调用。 } } […

2011-12-22 04:39 · javascript

javascript中的bind

http://www.prototypejs.org/api/function/bind In JavaScript, functions are executed in a specific context (often referred to as “scope”). Inside the function the this keyword becomes a reference to that scope . Since every function is in fact a property of some object—global functions are properties…

2011-12-21 04:08 · javascript