这几个输出有点不是很清楚,给解释一下呗

<!DOCTYPE html>

<html>


<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>Document</title>

</head>


<body>

    <script>

        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);

        }



        Foo.getName(); 

        getName(); 

        Foo().getName(); 

        getName(); 

        new Foo.getName(); 

        new Foo().getName(); 

        new new Foo().getName(); 

    </script>

</body>


</html>


郎朗坤
浏览 377回答 1
1回答
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

JavaScript