From da78a9e329e272dedb2400b79a3bdeebff387d47 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:42:17 -0500 Subject: initial commit --- files/ko/web/api/console/count/index.html | 102 ++++++++++++++++++++++++++++++ 1 file changed, 102 insertions(+) create mode 100644 files/ko/web/api/console/count/index.html (limited to 'files/ko/web/api/console/count/index.html') diff --git a/files/ko/web/api/console/count/index.html b/files/ko/web/api/console/count/index.html new file mode 100644 index 0000000000..0040da4c11 --- /dev/null +++ b/files/ko/web/api/console/count/index.html @@ -0,0 +1,102 @@ +--- +title: console.count() +slug: Web/API/Console/count +tags: + - API + - DOM + - Method + - Reference +translation_of: Web/API/Console/count +--- +
{{APIRef("Console API")}}
+ +

console.count() 메서드는 특정 count() 호출의 횟수를 세어 출력합니다.

+ +

{{AvailableInWorkers}}

+ +

구문

+ +
console.count([label]);
+ +

매개변수

+ +
+
label {{Optional_Inline}}
+
{{jsxref("String")}}. 지정한 경우, 이 레이블을 지정한 count() 호출의 수를 출력합니다. 누락한 경우 "default"를 지정한 것처럼 동작합니다.
+
+ +

예제

+ +
let user = "";
+
+function greet() {
+  console.count();
+  return "hi " + user;
+}
+
+user = "bob";
+greet();
+user = "alice";
+greet();
+greet();
+console.count();
+ +

위 코드의 출력 결과는 다음과 같은 형태입니다.

+ +
"default: 1"
+"default: 2"
+"default: 3"
+"default: 4"
+ +

레이블을 명시하지 않았기 때문에 default로 나타납니다.

+ +

첫 번째 count()의 매개변수에는 user 변수를 제공하고, 두 번째에는 문자열 "alice"를 제공할 경우...

+ +
let user = "";
+
+function greet() {
+  console.count(user);
+  return "hi " + user;
+}
+
+user = "bob";
+greet();
+user = "alice";
+greet();
+greet();
+console.count("alice");
+ +

다음과 같이 출력합니다.

+ +
"bob: 1"
+"alice: 1"
+"alice: 2"
+"alice: 3"
+ +
+
+ +

명세

+ + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName("Console API", "#count", "console.count()")}}{{Spec2("Console API")}}Initial definition
+ +

브라우저 호환성

+ + + +

{{Compat("api.Console.count")}}

-- cgit v1.2.3-54-g00ecf