无标题文章

function test(){
var x = 10;
var y = 20;
return function () {
alert(x);
alert(y);
};
}
var x = 30;
var y = 40;
var temp = test();
temp(); //10 20

    function A(){
    }
    A.prototype.x = 10;
    var al = new A();
    A.prototype = {x:20,y:30};
    var a2 = new A();
    alert(al.x);
    alert(al.y);
    alert(a2.x);
    alert(a2.y); //10 undefined 20 30 
    

    alert("5" + 3);  //53
    
    9题航空
    var prices = {
        a : {
            price : 100
        },
        b : {
            price : 500
        },
        c : {
            price : 200
        },
        d : {
            price : 400
        },
        e : {
            price : 300
        },
    }
    var arr = Object.keys(prices).sort(function (a,b) {
        return prices[a].price - prices[b].price
    });
    console.log(arr);
    for (var a in arr) {
        console.log(arr[a] + prices[arr[a]].price);
    }
    
    10题
    function f (a) {
        if (a == 0 || a == 1) {
            return 1;
        }
        return (f(a-1) + f(a-2));
    }
    console.log(f(4));

你可能感兴趣的:(无标题文章)