DEV Community

David Hwang
David Hwang

Posted on


5/13 TIL: Go & JS hashmap

  • hashmap improves run time complexities
  • hashMap equivalent in Javascript
let map = new Map()
map.set(key, value)
map.has(key) // true or false
Enter fullscreen mode Exit fullscreen mode
  • hashMap equivalent in Go
m = make(map[int]int)
// map types are reference types so simply doing 'var m map[int]int' will not point to an initialized map and it will be nil
m[key] // set value
result := m[key] // get value
_, ok := m[key] // returns true or false in the second param
delete(m, key)
Enter fullscreen mode Exit fullscreen mode
  • discrete math intro
    • set-roster vs. set-builder notation
    • set-builder example: { x ∈ reals | x ≥ 2 and x ≤ 6 }

Top comments (0)

An Animated Guide to Node.js Event Loop

>> Check out this classic DEV post <<