[ Web Proxy ]
URL:
Viewing: https://developer.mozilla.org/ko/docs/Web/JavaScript/Reference/Global_Objects/Object/values [Back]  [Original]

Object.values() - 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

Object.values()

Baseline Widely available

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

Object.values() ( ) . for...in . (for in .)

In this article

const object1 = {
  a: "somestring",
  b: 42,
  c: false,
};

console.log(Object.values(object1));
// Expected output: Array ["somestring", 42, false]

Syntax

js
Object.values(obj);

Parameters

obj

Return value

Description

Object.values() . for in . ( for in )

Examples

js
var obj = { foo: "bar", baz: 42 };
console.log(Object.values(obj)); // ['bar', 42]

//   (   )
var obj = { 0: "a", 1: "b", 2: "c" };
console.log(Object.values(obj)); // ['a', 'b', 'c']

//          .
var an_obj = { 100: "a", 2: "b", 7: "c" };
console.log(Object.values(an_obj)); // ['b', 'c', 'a']

// getFoo       .
var my_obj = Object.create(
  {},
  {
    getFoo: {
      value: function () {
        return this.foo;
      },
    },
  },
);
my_obj.foo = "bar";
console.log(Object.values(my_obj)); // ['bar']

//       .
console.log(Object.values("foo")); // ['f', 'o', 'o']

Polyfill

Object.values . . tc39/proposal-object-values-entries es-shims/Object.values .

Specification
ECMAScript 2027 LanguageSpecification
# sec-object.values

See also


Web Proxy Viewer  |  New URL  |  Original Page