标签:osi some position 操作 manager ons 数组 new ==
以下所有方法都是在操作源数组
根据条件修改源数组中的元素
let persons = [
{name:‘langkye‘,age:18},
{name:‘alex‘,age:20},
];
persons.some((person)=>{
if(person.name == ‘langkye‘){
person.position = ‘manager‘;
}
}
);
console.log(persons);
/*
* 0: {name: "langkye", age: 18, position: "manager"}
* 1: {name: "alex", age: 20}
*/
在数组末尾追加元素
let arr = new Array();
arr.push(0);
arr.push(1);
console.log(arr); // (3)?[0, 1, 3]
arr.push(‘element‘); // (4)?[0, 1, 3, "element"]
标签:osi some position 操作 manager ons 数组 new ==
原文地址:https://www.cnblogs.com/langkyeSir/p/13278217.html