What is “assert” in JavaScript?

后端 未结 14 692
-上瘾入骨i
-上瘾入骨i 2020-12-04 05:03

What does assert mean in JavaScript?

I’ve seen something like:

assert(function1() && function2() && function3(), \"some          


        
14条回答
  •  自闭症患者
    2020-12-04 05:34

    In addition to other options like console.assert or rolling your own, you can use invariant. It has a couple of unique features:

    • It supports formatted error messages (using a %s specifier).
    • In production environments (as determined by the Node.js or Webpack environment), the error message is optional, allowing for (slightly) smaller .js.

提交回复
热议问题