Skip to content

Instantly share code, notes, and snippets.

@neilkuan
Last active March 21, 2022 02:22
Show Gist options
  • Save neilkuan/e721244f6364b429df1977e5c0340f53 to your computer and use it in GitHub Desktop.
Save neilkuan/e721244f6364b429df1977e5c0340f53 to your computer and use it in GitHub Desktop.
example code for typescript
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