标签:
Learn about console.assert, which is syntactic sugar for logging an error the console when a given condition is not met. It‘s useful, but may not do what you expect if you‘re coming from another language - watch this lesson to learn how to use it, and when not to.
var foo = undefined; if(!foo){ console.log("Foo is undefined"); } // The same as var foo = undefined; console.assert(foo, "Foo is falsy value");
But notice, assert just log out the error message in the console, but it doesn‘t help to handle the error.
[Javascript] Proper use of console.assert in JavaScript
标签:
原文地址:http://www.cnblogs.com/Answer1215/p/5498259.html