[ Web Proxy ]
URL:
Viewing: https://developer.mozilla.org/ko/docs/Web/JavaScript/Reference/Operators/Property_accessors [Back]  [Original]

- JavaScript | MDN

This page was translated from English by the community. Learn more and join the MDN Web Docs community.

View in English Always switch to English

Baseline Widely available

This feature is well established and works across many devices and browser versions. Its been available across browsers since 2015 7.

.

In this article

const person1 = {};
person1["firstname"] = "Mario";
person1["lastname"] = "Rossi";

console.log(person1.firstname);
// Expected output: "Mario"

const person2 = {
  firstname: "John",
  lastname: "Doe",
};

console.log(person2["lastname"]);
// Expected output: "Doe"

js
object.property;
object["property"];

( , , , ) . , . , Function .

.

js
get = object.property;
object.property = set;

, property JavaScript . object.$1 object.1 .

js
document.createElement("pre");

"createElement" document .

, .

js
(77).toExponential();
// or
(77).toExponential();
// or
(77).toExponential();
// or
(77).toExponential();
// or
(77.0).toExponential();
// because 77. === 77.0, no ambiguity

js
get = object[property_name];
object[property_name] = set;

property_name Symbol . . "1foo", "!bar!", " "() .

js
document["createElement"]("pre");

.

.

js
document["createElement"]("pre");

Symbol. .

js
var object = {};
object["1"] = "value";
console.log(object[1]);

1 '1' , "value".

js
var foo = { unique_prop: 1 },
  bar = { unique_prop: 2 },
  object = {};
object[foo] = "value";
console.log(object[bar]);

foo bar (SpiderMonkey JavaScript "['object Object']") , "value".

. this this . , this "". .

eval()

JavaScript eval() . .

js
x = eval("document.forms.form_name.elements." + strFormControl + ".value");

eval() , . , strFormControl , ID . .

js
x = document.forms["form_name"].elements[strFormControl].value;

Specification
ECMAScript 2027 LanguageSpecification
# sec-property-accessors


Web Proxy Viewer  |  New URL  |  Original Page