const fruits = ['🍒','🍏','🍍','🍊']
fruits.forEach(function(value, aa,bb){
console.log('value',value);
console.log('aa',aa);
console.log('bb',bb);
})
fruits.forEach((vv)=>console.log(vv));
const item1 = {
name : '🥗',
price : 7900
};
const item2 = {
name : '🍟',
price : 3500
};
const item3 = {
name : '🥮',
price : 10900
};
const products = [item1, item2, item3, item2];
let found = products.find((value) => value.name == '🥮');
let found = products.find(function(value){
return value.name == '🥮'
});
found = products.findIndex((value) => value.name == '🥮');
let result = products.some((value) =>
value.name == '🧀'
);
result = products.every((value) => value.name == "🥮");
result = products.filter((value) => value.name == "🥮");
const nums = [1,2,3,4,5];
result = nums.map(function(item){
return item*2;
})
result = nums.map((item) => [1,2]);
result = nums.flatMap((item) => ['🍣', '🥑']);
const texts = ['hi', 'abc', 'zoo'];
texts.sort();
const numbers = [10,8,5,1];
numbers.sort();
numbers.sort((a,b) => a-b);
console.log('(a,b) => a-b 이용하여 sort',numbers);
출처 :
개발자를 위한 웹 기술