Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

第16期(2019-5-23):浅克隆 #18

Copy link
Copy link
@AMY-Y

Description

@AMY-Y
Issue body actions
        基础篇
        难度 
        
        //浅拷贝
        请写出下列代码的输出结果,为什么?

        //1.
        var a = 2 ;
        var a_copy = a ;
        a_copy  = 3;
        console.log(a);//?

        //2.数组1
        var arr = [1,2,3,4];
        var arr_copy = arr ;
        arr_copy.push(5);
        console.log(arr);//?
        //3.数组2
        var arr = [1,2,3,4];
        var arr_copy = arr ;
        arr_copy = [1,2,3,4,5];
        console.log(arr);//?
        console.log(arr_copy);//?

        //4.对象1
        var obj = {
            name:'sunshine',
            age:18
        };
        var obj_copy = obj ;
        obj_copy.name = '过客';
        console.log(obj.name);//?

        //5.对象2
        var obj = {
            name:'sunshine',
            age:18
        };
        var obj_copy = obj ;
        obj_copy = {
            name:'过客',
            age:18
        };
        console.log(obj.name);//?
        console.log(obj_copy.name);//?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.