Can you alter a Javascript function after declaring it?

前端 未结 12 815
佛祖请我去吃肉
佛祖请我去吃肉 2020-11-28 22:10

Let\'s say I have var a = function() { return 1; }. Is it possible to alter a so that a() returns 2? Perhaps by editing a

12条回答
  •  醉酒成梦
    2020-11-28 22:35

    Can you not just define it again later on? When you want the change try just redefining it as:

    a = function() { return 2; }
    

提交回复
热议问题