node.js中的console.assert方法使用说明

时间:2014-12-10    点击:63   

方法说明:

该方法和 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中的querystring.escape方法使用说明
node.js中的querystring.parse方法使用说明
node.js中的url.resolve方法使用说明
node.js中的url.parse方法使用说明
node.js中的url.format方法使用说明
> 返回     
地址:上海市普陀区胶州路941号长久商务中心 电话: QQ:
© Copyright 2012 上海网络 Product All Rights Reserved