怎么理解这道题的

https://www.nowcoder.com/questionTerminal/ebb10dcc642e4abdba41edf3fc8c8515
看了这道题,没太理解
function test() {
            this.flag = false;
            this.change = () => {
                // console.log(this) //test
                this.flag = true;
                console.log("button.flag",button.flag); //true
            };
        }
        const button = new test();
        document.addEventListener("click", button.change);

        function btn(){
            const button2 = new test()
            console.log("button2.flag",button2.flag) //false
        }
求大神解释

#求助#
全部评论
牛客的题貌似都是带解析的吧
点赞 回复 分享
发布于 2022-07-27 16:06

相关推荐

2024-12-21 18:48
西安邮电大学 C++
黑皮白袜臭脚体育生:按使用了什么技术解决了什么问题,优化了什么性能指标来写会更好另外宣传下自己的开源仿b站微服务项目,GitHub已经390star,牛客上有完整文档教程
点赞 评论 收藏
分享
评论
1
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务