方法说明:

该方法和 assert.ok() 相同。如果 表达式(expression)求值结果是false将会抛出一个 AssertionError 伴随着提示信息(message)

语法:

复制代码 代码如下:
console.assert(expression, [message])

接收参数:

expression            表达式

message               错误提示信息

例子:

复制代码 代码如下:
var a = 0;
console.assert(a == 1, 'error!');

源码:

复制代码 代码如下:
Console.prototype.assert = function(expression) {
  if (!expression) {
    var arr = Array.prototype.slice.call(arguments, 1);
    require('assert').ok(false, util.format.apply(this, arr));
  }
};

标签:
node.js,console.assert方法

免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
狼山资源网 Copyright www.pvsay.com

评论“node.js中的console.assert方法使用说明”

暂无“node.js中的console.assert方法使用说明”评论...