Skip to content

Instantly share code, notes, and snippets.

@maxam2017
Created January 8, 2021 15:26
Show Gist options
  • Save maxam2017/8d786da2edffcba98875f4a3899e5cee to your computer and use it in GitHub Desktop.
Save maxam2017/8d786da2edffcba98875f4a3899e5cee to your computer and use it in GitHub Desktop.
JavaScript is awesome

Logo

JavaScript Trick

umm...

  1. casting
'1' + 1 // 11
'1' - 1 // 0
1 + '1' - '1' // 10
  1. reserved word
var undefined = 1
undefined // 1

this feature is deprecated. undefined and NaN become non-writable property in modern browser and node

  1. 🍌
('b' - 'a' + + 'a' + 'a').toLowerCase() // banana
  1. sorting
[1, 2, 100].sort() // [1, 100, 2]
  1. unicode
'👨‍👩‍👧‍👧'.length // 11
  1. override length
const arr = [1, 2, 3, 4]
arr.length = 2
arr // [1, 2]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment