JS gets the length of the object and gets the key value of the object

Remember the length of the array very clearly, you can get it with .length, but the length of the object,...may not be able to tell for a while.

 You can’t use .length for object length, you can use Object.keys(obj);

 

Object.keys(obj) obtains the key value array of the object. First obtain the array, and then obtain the length of the array through .length, which is the length of the object. If you want to obtain the key value of the object, you can also use this method.

Guess you like

Origin blog.csdn.net/WYB_BOOM/article/details/126873773