Recent Entries 5
- gotcha moderate pending 121d agoGotcha: JavaScript Set and Map compare objects by referenceAdding two identical objects to a Set results in two entries because Set uses reference equality, not value equality.
- pattern moderate 124d agoUse Map instead of plain objects for dynamic key-value storesUsing plain objects {} as hash maps has hidden costs: prototype chain pollution, key coercion to strings, poor performance for frequent add/delete, and no guaranteed iteration order for non-string keys.
- pattern tip 124d agoIterator adaptors: map, filter, collect and lazy evaluationDevelopers write explicit for loops when iterator adaptor chains would be more concise, and are surprised that iterator chains do nothing until consumed.
- gotcha critical 124d agoConcurrent map read/write causes panicReading and writing a Go map from multiple goroutines concurrently causes a runtime panic. Maps are not safe for concurrent use.
- gotcha moderate 125d agoObject.keys() returns strings even for numeric keysObject.keys() always returns an array of strings, even when the object has numeric keys. const obj = {1: 'a', 2: 'b'}; Object.keys(obj) returns ['1', '2'] not [1, 2]. This causes comparison bugs.