[20220602 T]

devbit4 [front-end developer]Β·2022λ…„ 6μ›” 1일
0

TIL

λͺ©λ‘ 보기
60/163

🎈ARRAY

const arr = [1,2,3]

console.log(Array.isArray(arr))

πŸŽˆκ΅¬μ‘°λΆ„ν•΄ ν• λ‹Ή

function formatDate(targetDate){
	const [date] = targetDate.toISOString().split("T");
    
    const [year, momth, day] = date.split("-");
    
    return `${year}λ…„ ${month}μ›” ${day}일`
}

🎈Lodash처럼 μœ ν‹Έν•¨μˆ˜ λ§Œλ“€κΈ°

funtion head(arr){
	return arr[0] ??  ""
}

πŸŽˆμœ μ‚¬ λ°°μ—΄ 객체

μžλ°”μŠ€ν¬λ¦½μ˜ 배열은 객체 like λ…Έλ“œλ¦¬μŠ€νŠΈ, arguments

const arrayLikeObject = {

0: "Hello",
1: "World".
length: 2

}

Array.isArray
Array.from

const sufficWon = price => price + "원";
const isOverOneThousand = price => Number(price) > 1000
const ansendingList = (a,b) => a-b;

//function getWonPrice(priceList){
	const isOverList = priceList.filter(isOverOneThousand);
   	const sortList = isOverList.sort(ascendingList);
    
    return sortList.map(suffixWon);
}//

function getWonPrice(priceList){

    return priceList
    .filter(isOverOneThousand)
    .sort(ascendingList)
    .map(suffixWon);
}

🎈 λ°°μ—΄ λ§€μ„œλ“œ 체이닝

🎈 map vs forEach

Array.prototype.every() AND
Array.prototype.some() OR
Array.prototype.find()
Array.prototype.findIndex()

🎈 LOOKUP TABLE

function getUserType(type){
	const USER_TYPE={
    	ADMIN:"κ΄€λ¦¬μž",
        INSTRUCTOR:"강사",
        STUDENT:"학생"
    }
    
    return USER_TYPE[type]|| "ν•΄λ‹Ήμ—†μŒ"
}
function getUserType(type){
	return(
    	{
        	ADMIN: "κ΄€λ¦¬μž",
            INSTRUCTOR :"강사",
            STUDENT:"μˆ˜κ°•μƒ",
        }[type] ?? "ν•΄λ‹Ήμ—†μŒ"
    )
}

🎈 객체 ꡬ쑰뢄해할당

function Person(name, {age, location}){
	this.name = name;
    this.age = age;
    this.location = location;

}

const pocoOptions = {
	age: 30,
    location: "Korea"
}

const poco = new Person("poco", pocoOptions)
const orders = ["first", "second", "third"];

const {0: st2, 2: rd2} = orders;

console.log(st2);
console.log(rd2);

or

const [st2, ,rd3] = orders;

🎈 Object.freeze

Object.isFrozen(STATUS)

🎈 shallow copy vs deep copy

Object.keys
Object.values
Object.entries

profile
μ œλŒ€λ‘œ κΎΈμ€€ν•˜κ²Œ / λΈ”λ‘œκ·Έ 이전 => https://dailybit.co.kr

0개의 λŒ“κΈ€