First, JS to determine whether an object is an empty object
1) Judging by the. Stringify method that comes with the JSON.
// JSON-stringify method to turn JSON into JSON string var c =if(json.stringify (c) = = "{}") { Console.log ("is empty object"
2) for...in ... Traverse Properties
// for in var a = {}; var b = {foo: ' Bar '}; function AA (a) { for (var in a) { returnTrue ; } return false ;}
3) ES6 new Object.keys () to determine if the object keys is 0
if (Object.keys (obj). length==0) { console.log ("es6 by judging if the length of the key is 0: empty object"); } Else { console.log ("es6 by judging if the length of the key is 0: not an empty object"); }
Ii. Isemptyobject (obj) provided through jquery
Jquery.isemptyobject ({}); // truejquery.isemptyobject ({' foo ': ' Bar '}); // false
Http://jsbin.com/puguxefabe/edit?html,js,console,output
Js/jquery determines whether an object is empty