How to check if a function is already defined?

后端 未结 10 1567
后悔当初
后悔当初 2021-01-01 08:52

How to check if a function is already defined ?

10条回答
  •  盖世英雄少女心
    2021-01-01 09:35

    This is what I use to check if a function is already defined:

    if ( typeof(myFunc()) === 'undefined' )
    {
        console.log('myFunc undefined');
    }
    else 
    {
        console.log('myFunc defined');
    }
    

提交回复
热议问题