node.js中的console.assert方法使用说明
2014-12-10 00:00
851 查看
方法说明:
该方法和 assert.ok() 相同。如果 表达式(expression)求值结果是false将会抛出一个 AssertionError 伴随着提示信息(message)
语法:
接收参数:
expression 表达式
message 错误提示信息
例子:
源码:
该方法和 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方法使用说明
- node.js中的console.trace方法使用说明
- node.js中的console.time方法使用说明
- node.js中的console.time方法使用说明
- node.js中的console.trace方法使用说明
- node.js中的console.error方法使用说明
- node.js中的console.log方法使用说明
- node.js中的console.dir方法使用说明
- node.js中的console.dir方法使用说明
- node.js中的console.timeEnd方法使用说明
- node.js中的console.timeEnd方法使用说明
- node.js中的console.info方法使用说明
- node.js中的console.warn方法使用说明
- node.js中的console.error方法使用说明
- node.js中的console.warn方法使用说明
- node.js中的console.log方法使用说明
- node.js中的console.info方法使用说明
- node.js中的path.normalize方法使用说明
- node.js中的path.delimiter方法使用说明
- node.js中的buffer.write方法使用说明