原型函数中的最大堆栈大小

时间:2015-02-07 14:35:16

标签: javascript prototype

 <script>
        function employee(fname, lname) {
            this.fname = fname;
            this.lname = lname;
            this.fullname = function () {
                return this.fname + " " + this.lname;
            }
            
        }
        employee.prototype.sendtoserver = function () {
            $.post("/abc.aspx",this).done(function (data) {
                console.log(data);
            });
        }
        var johnny = new employee("johnny", "hkko");
        
    </script>

当我按下按钮时调用原型功能点击这样

<input type="button" onclick="johnny.sendtoserver()" value="fddfdfdf"/>`

达到最大堆栈大小,当我调试时发现它被多次调用,其中一个是johny,另一个是带窗口。

0 个答案:

没有答案