Array 배열
배열의 추가, 삭제 push, pop, shift, unshift, splice let arr = [1, 2, 3, 4, 5]; 1. 배열의 뒤에 추가, 삭제 arr.push() 배열의 맨 뒤에 요소를 넣는다. arr.push(6); console.log(arr); //[1, 2, 3, 4, 5, 6] arr.push(7,8); console.log(arr);//[1, 2, 3, 4, 5, 6,7,8] arr.pop() 배열의 맨 뒤의 요소를 하나만 삭제한다. let el =arr.pop(); console.log(arr, el);//[1, 2, 3, 4, 5, 6, 7] 8let arr =[1,2,3,4,5]; 2. 배열의 앞에 추가, 삭제 shift의 리턴값 => 빼낸 값 arr.unshift() 배..
2023. 6. 15.
Return
const easyCalcualtor = { plus : function (a, b){return(a + b);}, minus : function (a, b) {return(a - b);}, multiply : function (a, b) {return(a * b);}, devide : function (a, b) {return(a / b);}, power : function (a, b) {return(a ** b);}, }; const plusResult = easyCalcualtor.plus(2,3); const minusResult = easyCalcualtor.minus(plusResult,3); const multiplyResult = easyCalcualtor.multiply(2,minusRe..
2023. 4. 24.
Array
Array는 variables 안에 list를 추가하는 것 데이터를 나열하기 위한 방법 중 하나. 항상 [ ] 안에 콤마(,)로 데이터들을 나열한다. 변수도 쓰일 수 있고, boolean, text, 숫자 등 데이터 정렬이 가능하다. ex) const daysOfWeek = ["mon", "tue", "wed", "thu", "fri", "sat"]; //daysOfWeek이라는 변수 안에 배열 작성 console.log(daysOfWeek[5]); //5번째 인덱스는 =>fri daysOfWeek.push("sun"); //배열에 sun을 추가하면 const daysOfWeek = ["mon", "tue", "wed", "thu", "fri", "sat", "sun"];
2023. 4. 14.