LoginSignup
0
2

More than 1 year has passed since last update.

Object.values()の代替

Posted at

概要

Object.values()の代替

Object.values()

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

// ['bar', 42]

代替

Object.prototype.values = function(obj) {
    var res = [];
    for (var i in obj)
    {
        if (obj.hasOwnProperty(i))
        {
            res.push(obj[i]);
        }
    }
    return res;
};



以上。

0
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
2