Last active
March 21, 2022 02:22
-
-
Save neilkuan/e721244f6364b429df1977e5c0340f53 to your computer and use it in GitHub Desktop.
example code for typescript
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const apple = [1,2,3,4,5] | |
console.log('const of: ') | |
for (const num of apple) { | |
console.log(num) | |
} | |
// const of: | |
// 1 | |
// 2 | |
// 3 | |
// 4 | |
// 5 | |
console.log('ForEach: ') | |
apple.forEach(num => { | |
console.log(num) | |
}); | |
// ForEach: | |
// 1 | |
// 2 | |
// 3 | |
// 4 | |
// 5 | |
console.log('Match object: ') | |
const exist = apple.includes(1); | |
console.log(exist) | |
// Match object: | |
// true | |
console.log('Not match object: ') | |
const notexist = apple.includes(6); | |
console.log(notexist) | |
// Not match object: | |
// false |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment