Javascript delete a function

前端 未结 3 942
迷失自我
迷失自我 2020-12-14 07:51

How can I delete a function

i.e

test=true;
delete test;
=> true

function test() {..}

delete test()
=> false

Delete usually

3条回答
  •  难免孤独
    2020-12-14 08:28

    You could always do:

    var testFunc = func() 
    {
        // stuff here
    }
    
    //...
    testFunc();
    //...
    
    testFunc = undefined;
    

    delete in JavaScript has no bearing on freeing memory, see here

提交回复
热议问题