250x250
Notice
Recent Posts
Recent Comments
- Today
- Total
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- async
- mongoose
- flutter
- Node.js
- RDS
- await
- MYSQL
- findByIdAndDelete
- TypeScript
- css
- atlas
- jsonwebtoken
- TailwindCSS
- wil
- Express
- https
- mongodb
- certbot
- AWS
- clipBehavior
- Nodejs
- sequelize
- Find
- single quote
- nginx
- til
- JavaScript
- EC2
- moment
- double quote
Link
Archives
기억 휘발 방지소
[JavaScript] includes() 본문
728x90
반응형
includes()는 배열이 특정 요소를 포함하고 있는지를 판별하는 메소드이다.
const numbers = [1, 2, 3, 4, 5];
console.log(numbers.includes(5)); // true
console.log(numbers.includes(6)); // false
const names = ["Kim", "Park", "Lee"];
console.log(names.includes("Kim")); // true
console.log(names.includes("AAA")); // false
배열에 특정 요소가 포함되어 있다면 true를 반환하고 그렇지 않으면 false를 반환한다.
문자열에서도 쓸 수 있다!
const greeting = "Hello JavaScript";
console.log(greeting.includes("JavaScript")); // true
console.log(greeting.includes("Python")); // false
728x90
반응형
'Web > JavaScript' 카테고리의 다른 글
[JavaScript] shift()와 pop() (0) | 2021.10.05 |
---|---|
[JavaScript] sort() (0) | 2021.10.02 |
[JavaScript] find() (0) | 2021.09.24 |
[JavaScript] reduce() (0) | 2021.09.11 |
[JavaScript] async/await (0) | 2021.09.05 |