How to check if a function is already defined?

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

How to check if a function is already defined ?

10条回答
  •  时光说笑
    2021-01-01 09:39

    if (myFunc !== undefined) {
      // myFunc is defined
      foo();
    }
    

    or

    if (myFunc === undefined) {
      // myFunc is not defined
      qux();
    }
    

提交回复
热议问题