07-8-运算符的优先级

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<script>
    // . [] ()
    // ++ -- ! typeof
    // * / %
    // + -
    // > < >= <=
    // &&
    // ||
    // 三目
    // =
    // ,

    // let a = img || 9 && 0; //>>a=img
    // let a = img && 9 || 0; //>>a=9
    // console.log(a);

    // let b = 5;
    // let a = img || (a=6);
    // console.log(a); //>>a=img
    // console.log(b); //>>b=5
    //计算机惰性运算||的优先级最低不管后边取什么a=img

    let b = 5;
    let a = 8 || 5 && (b=6);
    console.log(a);//>>a=img
    console.log(b);//>>b=5
</script>
</body>
</html>

猜你喜欢

转载自www.cnblogs.com/zhangyu666/p/11479571.html