方法说明:
该方法和 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));
}
};
Statement:The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn