방법 설명 :
이 방법은 Assert.ok ()와 동일합니다. 표현식 (표현) 평가 결과가 거짓 인 경우 메시지와 함께 어설 러가 제기됩니다.
문법:
코드 사본은 다음과 같습니다.
console.assert (표현, [메시지])
매개 변수 수신 :
발현 발현
메시지 오류 메시지
예:
코드 사본은 다음과 같습니다.
var a = 0;
console.assert (a == 1, '오류!');
소스 코드 :
코드 사본은 다음과 같습니다.
Console.prototype.assert = function (expression) {
if (! expression) {
var arr = array.prototype.slice.call (인수, 1);
필요 ( 'assert'). Ok (false, util.format.apply (this, arr));
}
};