본문 바로가기

전체 글21

Part3 연산자 *long 타입을 제외한 정수 타입 연산은 int 타입으로 산출되고, 피연산자 중 하나라도 실수 타입이면 실수 타입으로 산출됩니다. 증감연산자 : ++,--를 말하며 변수의 값을 1씩 증가, 1씩 감소시킵니다. 비교연산자 : ==,!= 등을 말하며 값이 같은지, 다른지를 비교하고 boolean 값을 산출합니다. 논리연산자 : &&,||,! 등을 말하며 논리곱, 논리합, 논리부정을 수행하고 boolean 값을 산출합니다. 대입연산자 : =, +=, -= 등을 말하며 오른쪽의 값을 왼쪽에 대입하거나 연산 후 대입합니다. 삼항연산자 : (조건식)?A:B를 말하며 조건이 true이면 A를 산출, false이면 B를 산출합니다. 2021. 12. 27.
Part9 <배열 함수 10가지> 1. 배열을 string 문자열 하나로 합치기 => join const fruits = ['apple','banana','orange']; const result = fruits.join(' , '); =>괄호 안 구분자는 생략 가능 console.log(result); 2. string을 배열로 만들기 => split const fruits = 'apple,banana,cherry' const result = fruits.split(구분자,[제한자]); const result = fruits.split(',',2); -> ['apple','banana'] 3. 배열 내 데이터를 반대로 바꾸기 => reverse const array = [1,2,3,4,5]; const result = array.rev.. 2021. 12. 27.
Part 8 <Array 개념과 APIs> 비슷한 타입의 object들을 모아놓은 것(바구니) => 자료구조 1. 배열 선언 2가지 방법 const arr1 = new Array(); const arr2 = [1,2] =>0번에 1, 1번에 2 2. Index position const fruits = ['apple','banana']; console.log(fruits); console.log(fruits.length); ->2 console.log(fruits[0]); -> apple 배열의 마지막 데이터에 접근할 때 console.log(fruits[fruits.length - 1]); 3. looping over an array console.clear(); 1) for(let i = 0; i fruits.forEach((fruit) =>.. 2021. 12. 26.
Part 7 <Object> 1. literals & property primitive type은 변수 당 하나의 값만 담을 수 있음 const name = 'ellie'; const age = 4; print(name, age); function print(name, age) { console.log(name); console.log(age); } 문제는 담아야 할 정보 많으면 코드 점점 길어짐 하지만 object로 하면 function print(person) { console.log(person.name); console.log(person.age); } const ellie = {name: 'ellie', age:4}; print(ellie); *Object 만드는 방법 1. const obj1 = { };//object l.. 2021. 12. 26.