zoukankan      html  css  js  c++  java
  • js 运算符优先级

    运算符优先级:https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Operators/Operator_Precedence

    <!DOCTYPE html>
    <html lang="zh">
        <head>
            <meta charset="UTF-8">
            <meta name="viewport" content="width=device-width, initial-scale=1.0">
            <meta http-equiv="X-UA-Compatible" content="ie=edge">
            <title>运算符优先级</title>
        </head>
        <body>
            <script type="text/javascript">
                /* eslint-disable */
                function Foo() {
                    getName = function() {
                        console.log(1)
                    }
                    return this;
                }
                Foo.getName = function() {
                    console.log(2)
                }
                Foo.prototype.getName = function() {
                    console.log(3)
                }
                var getName = function() {
                    console.log(4)
                }
    
                function getName() {
                    console.log(5)
                }
                // 输出2 调用类的静态方法Foo.getName
                // Foo.getName()
    
                // 输出4 function getName()会进行提升,之后被var getName重新复制
                // getName()
    
                // 输出1 实例的方法
                // Foo().getName()
    
                // 输出2 new运算符的优先级低于.
                // new Foo.getName()
    
                // 输出3 https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Operators/Operator_Precedence 
                // 就是考察运算符优先级 我是不会这样写的 伤脑
                new Foo().getName()
    
                // 输出3 输出3 https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Operators/Operator_Precedence 
                // 就是考察运算符优先级 我是不会这样写的 伤脑
                // new new Foo().getName()
            </script>
        </body>
    </html>
  • 相关阅读:
    array_unshift() 、
    readfile() 函数
    Java的异常处理
    Java 接口
    Java 抽象类
    final关键字
    statice关键字
    dom查询
    JS 正则表达式
    JS对象
  • 原文地址:https://www.cnblogs.com/mengfangui/p/10535600.html
Copyright © 2011-2022 走看看