From da78a9e329e272dedb2400b79a3bdeebff387d47 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:42:17 -0500 Subject: initial commit --- .../global_objects/date/tojson/index.html | 81 ++++++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 files/ko/web/javascript/reference/global_objects/date/tojson/index.html (limited to 'files/ko/web/javascript/reference/global_objects/date/tojson/index.html') diff --git a/files/ko/web/javascript/reference/global_objects/date/tojson/index.html b/files/ko/web/javascript/reference/global_objects/date/tojson/index.html new file mode 100644 index 0000000000..5f069e3417 --- /dev/null +++ b/files/ko/web/javascript/reference/global_objects/date/tojson/index.html @@ -0,0 +1,81 @@ +--- +title: Date.prototype.toJSON() +slug: Web/JavaScript/Reference/Global_Objects/Date/toJSON +tags: + - Date + - JavaScript + - Method + - Prototype + - Reference +translation_of: Web/JavaScript/Reference/Global_Objects/Date/toJSON +--- +
{{JSRef}}
+ +

toJSON() 메서드는 {{jsxref("Date")}} 객체의 문자열 표현을 반환합니다.

+ +
{{EmbedInteractiveExample("pages/js/date-tojson.html")}}
+ + + +

구문

+ +
dateObj.toJSON()
+ +

반환 값

+ +

주어진 날짜의 문자열 표현.

+ +

설명

+ +

{{jsxref("Date")}} 인스턴스는 시간의 특정 지점을 가리킵니다. toJSON()을 호출하면 {{jsxref("Date.prototype.toISOString()", "toISOString()")}} 사용해 그 인스턴스가 가리키는 시간의 문자열 표현을 반환합니다. toJSON()은  Date 값을 {{Glossary("JSON")}}으로 직렬화할 때 유용하게 사용할 수 있도록 만들어졌습니다.

+ +

예제

+ +

toJSON() 사용하기

+ +
const jsonDate = (new Date()).toJSON();
+const backToDate = new Date(jsonDate);
+
+console.log(jsonDate); //2015-10-26T07:46:36.611Z
+
+ +

명세

+ + + + + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('ES5.1', '#sec-15.9.5.44', 'Date.prototype.toJSON')}}{{Spec2('ES5.1')}}Initial definition. Implemented in JavaScript 1.8.5.
{{SpecName('ES6', '#sec-date.prototype.tojson', 'Date.prototype.toJSON')}}{{Spec2('ES6')}} 
{{SpecName('ESDraft', '#sec-date.prototype.tojson', 'Date.prototype.toJSON')}}{{Spec2('ESDraft')}} 
+ +

브라우저 호환성

+ + + +

{{Compat("javascript.builtins.Date.toJSON")}}

+ +

같이 보기

+ + -- cgit v1.2.3-54-g00ecf