Object.values() (非标准)
来源:互联网 发布:全本天庭淘宝店txt下载 编辑:程序博客网 时间:2024/06/05 09:33
The Object.values()
method returns an array of a given object's own enumerable property values, in the same order as that provided by a for...in
loop (the difference being that a for-in loop enumerates properties in the prototype chain as well).
Syntax
Object.values(obj)
Parameters
obj
- The object whose enumerable own property values are to be returned.
Description
Object.values()
returns an array whose elements are strings corresponding to the enumerable property values found directly upon object
. The ordering of the properties is the same as that given by looping over the property values of the object manually.
Examples
var obj = { foo: "bar", baz: 42 };console.log(Object.values(obj)); // ['bar', 42]// array like objectvar obj = { 0: 'a', 1: 'b', 2: 'c' };console.log(Object.values(obj)); // ['a', 'b', 'c']// array like object with random key orderingvar an_obj = { 100: 'a', 2: 'b', 7: 'c' };console.log(Object.values(an_obj)); // ['b', 'c', 'a']// getFoo is property which isn't enumerablevar my_obj = Object.create({}, { getFoo: { value: function() { return this.foo; } } });my_obj.foo = "bar";console.log(Object.values(my_obj)); // ['bar']// non-object argument will be coerced to an objectconsole.log(Object.values("foo")); // ['f', 'o', 'o']
Polyfill
To add compatible Object.values
support in older environments that do not natively support it, you can find a Polyfill in the tc39/proposal-object-values-entries or in the es-shims/Object.valuesrepositories.
Specifications
The definition of 'Object.values' in that specification.DraftInitial definition.
Browser compatibility
- Desktop
- Mobile
[1] Behind a flag.
[2] See bug 150131.
See also
- Enumerability and ownership of properties
Object.keys()
Object.entries()
Object.prototype.propertyIsEnumerable()
Object.create()
Object.getOwnPropertyNames()
- Object.values() (非标准)
- Object... values 可变参数
- Object... values 的含义
- Object...values可变参数和Object[] values区别
- es6 javascript对象Object.values() , Object.entries()
- ES6-对象的扩展-Object.keys(),Object.values(),Object.entries()
- Comparing Object Values Using Hash Codes
- 获取Object的所有keys or values
- 获取Object的所有keys or values
- 'numpy.ndarray' object has no attribute 'values'
- Object..values可变参数列表,可理解为object[]数组类型
- values
- Using Groovy to read values from a different view object
- Dot notation vs. bracket notation when retriving object property values
- 非标准输入
- Convert array of key value object to object of the key values (ruby)
- Identifying multiple/single values of metadata and recording into XML via .NET Client Object Model
- tsql default values, check current isolation level, check db object last update time
- [转]SQL触发器
- IOS性能调优系列:Analyze静态分析
- TextView下来收键盘
- ActionBar的一些方法说明
- Logistic Regression- Maximize Likelihood and Minimize Cost-Function
- Object.values() (非标准)
- Objective-C Runtime 运行时之一:类与对象
- AngularJS过滤器(Filters)
- git 命令大全
- Qt双缓冲机制:实现一个简单的绘图工具(纯代码实现)
- Required background modes [info.plist 配置后台运行模式]
- 奋斗吧,程序员——第五十四章 坐拥美人君莫笑,古来征战几人回
- Object.entries()
- Android总结篇系列:Android广播机制