考题

var x = 3;

var foo = {
    x: 2,
    baz: {
        x: 1,
        bar: function() {
            return this.x;
        }
    }
}

var go = foo.baz.bar;

alert(go());   //3
alert(foo.baz.bar());   //1

 

var x = 4,
    obj = {
        x: 3,
        bar: function() {
            var x = 2;
            
                
                alert(this.x);

        }
    };
obj.bar();     //3

 

 

 

var x = 4,
    obj = {
        x: 3,
        bar: function() {
            var x = 2;
            (function() {
                var x = 1;
                alert(this.x);
            })()
        }
    };
obj.bar();     //4

 

 

var foo = function bar() {alert(typeof bar);};
alert(typeof bar);    //undefined    ie8以下是function
foo();   //function

 

 

[[1,2,3],5,6, [[7,8], 9]]

function arrParse(arr){
	for(var i=0; i<arr.length; i++){
		if(arr[i].length > 1){
			arrParse(arr[i]);
			continue;
		}
		console.log(arr[i]);

	}
}

 

posted @ 2014-03-07 15:04  Western Journey  阅读(186)  评论(0编辑  收藏  举报