0
我有这样的对象:离子2,遍历对象
{"": "Select job type", F: "Full-time", P: "Part-time", C: "Contract", T: "Temporary}
我希望能够通过它循环,并得到键和值。我打算写一个函数,看起来像
getJobType(letter){
let jobType = JSON.parse(localStorage.getItem('jobType'))
//if my letter matches the key in the object then i want to return the value
}
我曾尝试:
Object.keys(JSON.parse(jobType)).forEach(key=> {
console.log(jobType[key]) ;
});
和
jobType.forEach((value, key, index) => {
console.log("This is the value", value)
console.log("from the key", key)
})
,但它不工作。