| [ Web Proxy ] |
| Viewing: https://developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Global_Objects/Object/values | [Back] [Original] |
Get to know MDN better
Object.values()
const object = {
a: "some string",
b: 42,
c: false,
};
console.log(Object.values(object));
// : Array ["somestring", 42, false]
Object.values(obj)
Object.values() object for...in for...in Object.values() for...in
Object.keys() Object.entries()
const obj = { foo: "bar", baz: 42 };
console.log(Object.values(obj)); // ['bar', 42]
//
const arrayLikeObj1 = { 0: "a", 1: "b", 2: "c" };
console.log(Object.values(arrayLikeObj1)); // ['a', 'b', 'c']
//
//
const arrayLikeObj2 = { 100: "a", 2: "b", 7: "c" };
console.log(Object.values(arrayLikeObj2)); // ['b', 'c', 'a']
// getFoo
const myObj = Object.create(
{},
{
getFoo: {
value() {
return this.foo;
},
},
},
);
myObj.foo = "bar";
console.log(Object.values(myObj)); // ['bar']
//
console.log(Object.values("foo")); // ['f', 'o', 'o']
// undefined null
console.log(Object.values(100)); // []
| ECMAScript 2027 LanguageSpecification # sec-object.values |
Objectassign()create()defineProperties()defineProperty()entries()freeze()fromEntries()getOwnPropertyDescriptor()getOwnPropertyDescriptors()getOwnPropertyNames()getOwnPropertySymbols()getPrototypeOf()groupBy()hasOwn()is()isExtensible()isFrozen()isSealed()keys()preventExtensions()seal()setPrototypeOf()values()Object/Function| Web Proxy Viewer | New URL | Original Page |