const generateNum = (array, key) => {
return array.map(i => parseFloat(i[key]));
}
A simple example for explanation.
let person = {
name: 'John',
age: 30,
};
let key = 'name';
person.key; // does not exist (only name and age is inside person object) so it would be undefined
person[key]; // exists because it means person.name actually
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…