
let name="noona's fruit store"
let fruits = ["banana","apple","mango"]
let address="Seoul"
let store = {name:name, fruits:fruits, address:address}
console.log(store)
๐ฑ ๋ต
let name="noona's fruit store" let fruits = ["banana","apple","mango"] let address="Seoul" let store = {name, fruits, address} console.log(store) //{address:"Seoul", fruits : ['banana','apple','mango'], name: "noona's fruit store"}
๐ฑ ๋ต
console.log(`์ ๊ฐ๊ฒ ์ด๋ฆ์ ${name} ์ ๋๋ค. ์์น๋ ${address} ์ ์์ต๋๋ค.`); // ์ ๊ฐ๊ฒ ์ด๋ฆ์ noona's fruit store ์ ๋๋ค. ์์น๋ Seoul ์ ์์ต๋๋ค.
function calculate(obj){ // ํจ์ ์์ ๋ฐ๊พธ์์ค
return a+b+c
}
calculate({a:1,b:2,c:3})
๐ฑ ๋ต
function calculate(obj){ // ํจ์ ์์ ๋ฐ๊พธ์์ค let {a,b,c}=obj; return a+b+c } calculate({a:1,b:2,c:3})
let name="noona store"
let fruits = ["banana","apple","mango"]
let address={
country:"Korea",
city:"Seoul"
}
function findStore(obj){
return name="noona store" && city == "Seoul"
}
console.log(findStore({name,fruits,address}))
๐ฑ ๋ต
let name="noona store" let fruits = ["banana","apple","mango"] let address={ country:"Korea", city:"Seoul" } function findStore(obj){ let {name,address:{city}} = obj return name="noona store" && city == "Seoul" } console.log(findStore({name,fruits,address}))
function getNumber(){
let array = [1,2,3,4,5,6] // ์ฌ๊ธฐ์๋ถํฐ ๋ฐ๊พธ์์ค
return {first,third,forth}
}
console.log(getNumber()) // ๊ฒฐ๊ณผ๊ฐ { first: 1, third: 3, forth: 4 }
๐ฑ ๋ต
function getNumber(){ let array = [1,2,3,4,5,6] // ์ฌ๊ธฐ์๋ถํฐ ๋ฐ๊พธ์์ค let [first,,third,forth]=array; return {first,third,forth} } console.log(getNumber()) // ๊ฒฐ๊ณผ๊ฐ { first: 1, third: 3, forth: 4 }
function getCalendar(first, ...rest) {
return (
first === "January" &&
rest[0] === "Febuary" &&
rest[1] === "March" &&
rest[2] === undefined
);
}
console.log(getCalendar()); // ์ฌ๊ธฐ๋ฅผ ๋ฐ๊พธ์์ค
๐ฑ ๋ต
function getCalendar(first, ...rest) { return ( first === "January" && rest[0] === "Febuary" && rest[1] === "March" && rest[2] === undefined ); } console.log(getCalendar("January","Febuary","March")); // ์ฌ๊ธฐ๋ฅผ ๋ฐ๊พธ์์ค
function getMinimum(){
let a= [45,23,78]
let b = [54,11,9]
return Math.min() // ์ฌ๊ธฐ๋ฅผ ๋ฐ๊พธ์์ค
}
console.log(getMinimum())
๐ฑ ๋ต
function getMinimum(){ let a= [45,23,78] let b = [54,11,9] return Math.min(...a,...b); // ์ฌ๊ธฐ๋ฅผ ๋ฐ๊พธ์์ค } console.log(getMinimum()); //9
function sumNumber() {
// ์ฌ๊ธฐ์๋ถํฐ ๋ฐ๊พธ์์ค
const sum = function (a, b) {
return a + b;
};
return sum(40, 10);
}
๐ฑ ๋ต
function sumNumber() { const sum =((a, b)=>{ return a + b; }); return sum(40, 10); } console.log(sumNumber()); //50
function sumNumber() {
//์ฌ๊ธฐ๋ฅผ ๋ฐ๊พธ์์ค
return addNumber(1)(2)(3);
function addNumber(a) {
return function (b) {
return function (c) {
return a + b + c;
};
};
}
}
console.log(sumNumber());
๐ฑ ๋ต
function sumNumber() { let addNumber =(a)=>(b)=>(c)=> a+b+c; return addNumber(1),(2),(3); } console.log(sumNumber()); //3