How do I check for the existence of a variable

This question already has an answer here:

  • JavaScript check if variable exists (is defined/initialized) 28 answers

  • Just use typeof :

    console.log(typeof FooClass) // undefined
    console.log(typeof FooClass === 'undefined') // true
    

    I doubt there's any need to use language features specific to TypeScript.

    链接地址: http://www.djcxy.com/p/95014.html

    上一篇: JavaScript检查变量是否存在(已定义/初始化)

    下一篇: 我如何检查变量的存在