Skip to content

高三精读小组课后作业(02期) #14

Description

@VaJoy

#68-174页

答案将于一周后更新于本贴,大家可以跟帖写答案看自己对基础知识的掌握程度如何。
跟帖回答案的都应自行思考完成,不然没有任何意义

1.说出下述代码的结果:

    var arr = [1];
    deal = function(arrA, arrB){
        return arrA.concat(arrB)
    };

    alert(deal.length);
    alert(deal(arr, [3, 4]));
    alert(arr);

2.填写下方代码缺失部分:

var s = "I love fat bats, cat and every Xat",
    reg = /________/g;   //填写此处缺失部分,过滤全部非结尾的Xat / Xats
s = s.replace(reg,"");
alert(s);  //"I love , and every Xat"

3.说出下方代码的运行结果:

    var s1 = 'abc',
        s2 = new String(s1);
    s1.color = 'blue';
    s2.color = 'red';
    console.log(s1===s2, s1===s2.toString(), s1===s2.valueOf());
    console.log(s1.color, s2.color)

4.闭上眼睛想一想,数组的方法你一共记得哪些?其中哪些方法是有返回值的呢?

5.补全下方函数:

var fruits = ["apple", "grape", "pear", "orange","banana"];
function pickSome(arr,min,max){
    //补全此处函数
}
alert(pickSome(fruits,2,4));   //随机返回2到4个水果

6.说出下方脚本的执行结果,看看你大概能答对几个:

    var P = function(){};
    P.prototype.aaa = function(){
        alert('ddd')
    };
    var a = new P(),
        b = new P();
    b.prototype = P;
    b.prototype.aaa = function(){
        alert('cc')
    };
    var c = Object.create(null),
        d = new Object();

    console.log(P.__proto__);
    console.log(P.prototype);
    console.log(a.__proto__);
    console.log(a.prototype);
    console.log(b.prototype);
    console.log(c.__proto__);
    console.log(d.__proto__);
    console.log(Number.__proto__);
    console.log(Number.prototype);
    console.log(Function.__proto__);
    console.log(Function.prototype);
    console.log(Function.prototype.__proto__);
    console.log(Object.__proto__);
    console.log(Object.prototype);
    console.log(Object.prototype.__proto__);

7.说出下方代码的运行结果:

    function a(){
        this.ha = 1
    }
    a.haha = 2;
    a.test = function(){
        console.log(this.ha)
    };
    a.prototype.test = function(){
        console.log(this.ha);
        console.log(this.haha)
    };
    a.prototype.test2 = 3;

    a.test();
    console.log(a.test2);
    var b = new a();
    console.log(b.haha);
    b.test()

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions