Get the attribute key of the json object in js

1. Use   of Object.keys

Array of keys in the output object whose value is greater than 2
var data = {a: 1, b: 2, c: 3, d: 4};
Object.keys(data).filter(function(x) { return  1 ;})
Expected output: ["c","d"]
Please fill in what ?
 

Correct answer: 1  : data[x]>2


This is a new syntax for Es5.
const keys = Object. keys (options);   //Only get the attribute key of the json object, and return an array that stores all the keys.


Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325506156&siteId=291194637