Lodash _.valuesIn() 方法
_.valuesIn()方法用于返回对象自己的和继承的可枚举字符串键控属性值的数组。
句法:
_.valuesIn(object)
参数:此方法接受如上所述和如下所述的单个参数:
- object:此参数保存要查询的对象。
返回值:此方法返回对象元素的属性值数组。
示例 1:
Javascript
// Requiring the lodash library
const _ = require("lodash");
// The source object
var obj = {
Name: "GeeksforGeeks",
password: "gfg@1234",
username: "your_geeks"
}
// Use of _.valuesIn() method
console.log(_.valuesIn(obj));
Javascript
// Requiring the lodash library
const _ = require("lodash");
// The source function
function Fb() {
this.id = 2045;
this.username = 'fb_myself';
this.password = 'fb1234';
}
Fb.prototype.email = 'myself@gmail.com';
// Use of _.valuesIn() method
console.log(_.valuesIn(new Fb));
输出:
["GeeksforGeeks", "gfg@1234", "your_geeks"]
示例 2:
Javascript
// Requiring the lodash library
const _ = require("lodash");
// The source function
function Fb() {
this.id = 2045;
this.username = 'fb_myself';
this.password = 'fb1234';
}
Fb.prototype.email = 'myself@gmail.com';
// Use of _.valuesIn() method
console.log(_.valuesIn(new Fb));
输出:
[2045, "fb_myself", "fb1234", "myself@gmail.com"]