A, today I want to write is a SAO operation of the object, usually we may also often use, because this is very useful, especially in doing some value matching is very useful. Come on, code.

const obj = {
0:'incorrect'.1:'right'} objects have a traversal method that isfor in
for(let item in obj){
console.log(item)
}

Copy the code

Those of you who have done this know that the answer is 0,1. Why? Because the object is traversed to get its index, which is actually its address, so we probably don’t use this method very often but it’s certainly nice to use it in another way.

const obj = {
0:'incorrect'.1:'right'
}
const status = 1; So when we receive a status return from the back end, the status value is1Obj [status] = obj[status] = obj[statusCopy the code

This is good for the front end to write the enumeration dead, and then the back end only returns a status value, but the front end needs to display its Chinese name or other name, this is very useful, did you get it