일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | |||||
3 | 4 | 5 | 6 | 7 | 8 | 9 |
10 | 11 | 12 | 13 | 14 | 15 | 16 |
17 | 18 | 19 | 20 | 21 | 22 | 23 |
24 | 25 | 26 | 27 | 28 | 29 | 30 |
31 |
- java
- 자바
- 자바 if문
- 자바 공배수
- 항해99 2기
- react ag grid
- 항해99
- 자바 삼항연산자
- Til
- 자바 자동캐스팅
- 자바 반복문
- 조코딩
- 자바 조건문
- 자바 구구단 출력
- 변수
- 프로그래머스
- 타입스크립트
- MySQL
- 자바 for문
- 정보처리기사실기
- 자바 스캐너
- 자바 while문
- 자바 public
- react with typescript
- 자바 switch문
- 자바 강제 캐스팅
- 이클립스 DB연동
- TypeScript
- Vue3
- 자바 향상된 for문
- Today
- Total
목록WEB/Java Script (37)
뇌 채우기 공간

function isAnimal(text){ return (text ==='고양이'|| text ==='개'|| text ==='거북이'); } console.log(isAnimal('개')); console.log(isAnimal('노트북')); 이렇게 여러가지 값을 받아서 확인해야할 경우가 있다. function isAnimal(text){ const animals = ['고양이','개','거북이']; // 배열의 내장함수 //배열 안에 포함되면 true가 나오고 아니면 false가 나옴 return animals.includes(text); } console.log(isAnimal('개')); console.log(isAnimal('노트북')); 그럴때는 배열을 사용하면 된다. 그리고 배열의 내장함..
const object = { a: 1, b: 2 }; const { a, b } = object; console.log(a); // 1 console.log(b); // 2 객체에서 값을 꺼내주기 위해서 이렇게 사용한다. 비구조화 할당은 함수의 파라미터에서도 사용할 수 있다. const object = { a: 1, b: 2 }; function print({ a, b }) { console.log(a); console.log(b); } print(object); 그런데 여기서b에 값이 없다고 가정해보겠다. const object = { a: 1 }; function print({ a, b }) { console.log(a); console.log(b); } print(object); // 1 // u..
논리연산자를 사용할때 꼭 true나 false를 사용하지 않아도 된다 truthy한 값이나 falsy한 값을 사용해도된다. const dog ={ name : '멍멍이' }; function getName(animal){ if(animal){ return animal.name; } return undefined; } const name = getName(dog); console.log(name); 이렇게 코드를 작성해주었다. getName이라는 function이 있는데 파라미터로 아무것도 적지 않으면 undefined를 리턴하겠다 이다. const dog ={ name : '멍멍이' }; function getName(animal){ return animal && animal.name; } const n..

function print(person){ if(person === undefined || person === null){return;} console.log(person.name); } const person = { name : 'John' }; print(person); if문에 있는 것은 null 과 undefined일 때 조건을 적용해주는 것이다. 에러가 나지 않게 그런데 매번 이렇게 할 수 없다. 있긴한데 더 좋은 방법이 있음 function print(person){ if(!person){return;} console.log(person.name); } const person = { name : 'John' }; print(person); 바로 !person이라고 쓰면 위의 값과 똑같다 왜냐?..
codition ? true : false const array = []; let text = ''; if(array.length === 0){ text ='배열이 비어있습니다.'; }else{ text = '배열이 비어있지 않습니다.'; } console.log(text); 삼항 연산자를 사용 안했을때 const array = []; let text = array.length === 0? '배열이 비어있습니다.': '배열이 비어있지 않습니다'; console.log(text); 삼항 연산자 사용 const condition1 = false; const condition2 = false; const value = condition1 ? '와우': condition2?'blabla': 'foo'; cons..