The js loop fetches the properties of the object

an object

state={
    new1:1,
    new2:2,
    new3:3,
    old1:1,
    old2:2
}

what should I do if I want to loop out the value of state.new1 state.new2state.new3
do not take out old1 old2

for example, get state.new1 in the first loop and state.new2 in the second time

for(var i=0;i<3;iPP){
     state.new1 
     state.new2
}
Mar.13,2021

for(var value in state){
    console.log(state[value])
}


enumerablefalsefor in:

function notEnum (obj, keys) {
  keys.forEach(key => {
    let def = Object.getOwnPropertyDescriptor(obj, key)
    def.enumerable = false
    Object.defineProperty(obj, key, def)
  })
}
var state = {
    new1:1,
    new2:2,
    new3:3,
    old1:1,
    old2:2
}
notEnum(state, ['old1', 'old2']) // old1old2
for (let i in state) {
  console.log(i)
}
Menu