const关键字

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    
</body>
<script>
    // 声明常量
    const SCHOOL='交大'
    // 1一定要赋初值
    // const A;
    // 2一般常量使用大写(潜规则)
    // const a=100;
    // 3常量的值不能修改
    // SCHOOL='北大'
    // 4块级作用域
    // {
    //     const PLAYER='UZI'
    // }
    // console.log(PLAYER)
    // 5对于数组对象的元素修改,不算对常量的修改,不会报错
    // const TEAM=['UZI','MING'];
    // 不报错
    // TEAM.push('Meiko');
    // 报错
    // TEAM=100;

    // 解构赋值
    // 1数组结构
    const F4=['小沈阳','刘能','宋小宝','赵四']
    let [xiao,liu,zhao,song]=F4
    console.log(xiao)
    console.log(liu)
    console.log(zhao)
    console.log(song)
    // 2对象的结构
    const ZBS={
        name:'赵本山',
        age:'不详',
        xiaopin:function(){
            console.log("我可以演小品");
        }
    }
    let {name,age,xiaopin}=ZBS;
    console.log(name)
    console.log(age)
    console.log(xiaopin)
    xiaopin()
</script>
</html>

 

posted @ 2024-12-25 14:43  鲁班大师智商二百五  阅读(23)  评论(0)    收藏  举报