es6解构赋值

<script type="text/javascript">

    let obj = {username:'java1234',pwd:'123456'};
   /* let username=obj.username;
    let pwd=obj.pwd;*/
    let{username,pwd} = obj;
    console.log(username,pwd);

    function func({username,pwd}){
        console.log(username,pwd);
    }

    func(obj);

    let arr=[1,4,2,'ccc',false,'啦啦啦'];
    let[,,,a,b]=arr;
    console.log(a,b);
</script>

 

posted @ 2020-07-26 09:50  爱跑步的乌龟  阅读(90)  评论(0编辑  收藏  举报