代码示例:(标识:jsck_console_assert_2)
<!DOCTYPE html>
<html>
<body>

<h1>JavaScript console.assert() 方法</h1>

<p>按键盘上的 F12 可在控制台视图中查看消息。</p>

<p>本例演示使用 console.assert 方法时对象的显示方式。</p>

<script>
var myObj = { firsname : "Bill", lastname : "Gates" };

console.assert(document.getElementById("demo"), myObj);
</script>

</body>
</html>
运行结果: