码迷,mamicode.com
首页 > 编程语言 > 详细

[Javascript] Proper use of console.assert in JavaScript

时间:2016-05-16 17:00:46      阅读:288      评论:0      收藏:0      [点我收藏+]

标签:

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!