3-5、不适用箭头函数的场景

50 阅读1分钟
<script>
    // 1.作为构造函数
    // 箭头函数没有this
    // const Person = () => { }
    // new Person();


    // 2.需要this指向调用对象的时候
    // document.onclick = function () {
    //     console.log(this);
    // };
    // document.addEventListener('click', () => {
    //     console.log(this);
    // })

    // 3.需要使用arguments的时候
    // function add() {
    //     console.log(arguments);
    // }
    // add(1, 2)

    // const add = () => console.log(arguments);
    // add(1, 2)
</script>