aboutsummaryrefslogtreecommitdiff
path: root/files/ko/web/api/console/assert/index.html
diff options
context:
space:
mode:
Diffstat (limited to 'files/ko/web/api/console/assert/index.html')
-rw-r--r--files/ko/web/api/console/assert/index.html99
1 files changed, 99 insertions, 0 deletions
diff --git a/files/ko/web/api/console/assert/index.html b/files/ko/web/api/console/assert/index.html
new file mode 100644
index 0000000000..3ad2aafa8e
--- /dev/null
+++ b/files/ko/web/api/console/assert/index.html
@@ -0,0 +1,99 @@
+---
+title: console.assert()
+slug: Web/API/Console/assert
+tags:
+ - API
+ - DOM
+ - Method
+ - Reference
+ - console
+translation_of: Web/API/console/assert
+---
+<div>{{APIRef("Console API")}}</div>
+
+<p><code><strong>console.assert()</strong></code> 메서드는 주어진 가정이 거짓인 경우 콘솔에 오류 메시지를 출력합니다. 참인 경우, 아무것도 하지 않습니다.</p>
+
+<p>{{AvailableInWorkers}}</p>
+
+<h2 id="구문">구문</h2>
+
+<pre class="syntaxbox">console.assert(<em>assertion</em>, <em>obj1</em> [, <em>obj2</em>, ..., <em>objN</em>]);
+console.assert(<em>assertion</em>, <em>msg</em> [, <em>subst1</em>, ..., <em>substN</em>]); // c-like message formatting
+</pre>
+
+<h3 id="Parameters">Parameters</h3>
+
+<dl>
+ <dt><code>assertion</code></dt>
+ <dd>아무 불리언 표현식. 거짓인 경우, 메시지를 콘솔에 출력합니다.</dd>
+ <dt><code>obj1</code> ... <code>objN</code></dt>
+ <dd>출력에 사용할 JavaScript 객체. 각각의 문자열 표현을 순서대로 출력합니다.</dd>
+ <dt><code>msg</code></dt>
+ <dd>0개 이상의 치환 문자열을 포함하는 JavaScript 문자열.</dd>
+ <dt><code>subst1</code> ... <code>substN</code></dt>
+ <dd><code>msg</code> 매개변수의 치환 문자열에 대입할 JavaScript 객체.</dd>
+</dl>
+
+<h2 id="예제">예제</h2>
+
+<p>다음 예제는 객체와 가정을 함께 사용하는 법을 보입니다.</p>
+
+<pre class="brush: js">const errorMsg = 'the # is not even';
+for (let number = 2; number &lt;= 5; number += 1) {
+ console.log('the # is ' + number);
+ console.assert(number % 2 === 0, {number: number, errorMsg: errorMsg});
+  // or, using <a href="/ko/docs/Web/JavaScript/Reference/Operators/Object_initializer">ES2015 object property shorthand</a>:
+ // console.assert(number % 2 === 0, {number, errorMsg});
+}
+// output:
+// the # is 2
+// the # is 3
+// Assertion failed: {number: 3, errorMsg: "the # is not even"}
+// the # is 4
+// the # is 5
+// Assertion failed: {number: 5, errorMsg: "the # is not even"}
+</pre>
+
+<p>참고로, {{domxref("console.log()")}}의 치환 문자열을 거의 모든 브라우저에서 정상 동작하지만...</p>
+
+<pre class="brush: js">console.log('the word is %s', 'foo');
+// output: the word is foo
+</pre>
+
+<p><code>console.assert()</code>의 치환 문자열은 일부 브라우저에서 동작하지 않습니다.</p>
+
+<pre class="brush: js">console.assert(false, 'the word is %s', 'foo');
+// correct output in Node.js and some browsers
+// (e.g. Firefox v60.0.2):
+// Assertion failed: the word is foo
+// incorrect output in some browsers
+// (e.g. Chrome v67.0.3396.87):
+// Assertion failed: the word is %s foo
+</pre>
+
+<p>{{domxref("console")}} 문서의 <a href="/ko/docs/Web/API/Console#Outputting_text_to_the_console">콘솔에 텍스트 출력하기</a> 항목도 참고하세요.</p>
+
+<h2 id="명세">명세</h2>
+
+<table class="standard-table">
+ <thead>
+ <tr>
+ <th scope="col">Specification</th>
+ <th scope="col">Status</th>
+ <th scope="col">Comment</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <td>{{SpecName("Console API", "#assert", "console.assert()")}}</td>
+ <td>{{Spec2("Console API")}}</td>
+ <td>Initial definition</td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="브라우저_호환성">브라우저 호환성</h2>
+
+
+
+<p>{{Compat("api.Console.assert")}}</p>