Quick JavaScript Tip: Emptying an array without losing reference

Published April 17, 2020, 1 min read, tagged as: javascriptcodequick tip

Quick JavaScript Tip: Overwriting an array's length property gives us an easy way to truncate and clear its content.

const arr = [11, 22, 33, 44, 55, 66]

// truncate array
arr.length = 3 // [11, 22, 33]

// clear array without losing reference
arr.length = 0 // []

I tweet about this type of thing a lot. If you enjoyed this article, you may enjoy following me.

April 13, 2020, 1 min read
javascriptcodequick tip

Quick JavaScript Tip: Storing unique data using Sets

Quick JavaScript Tip: Sets in JavaScript are a great way to store unique values. You can even convert Arrays to Sets to deduplicate them.

Read more

World Class Teams Create World Class Products

A Guide for Tech Leaders Navigating Growth and Change.

I'm writing a book! I share:

  • My framework to define and achieve engineering goals so you can move the needle in your organization and keep everyone rowing in the same direction
  • How to retain top tech talent and build high-performing teams
  • How to release great products rapidly with a structured Software Development Lifecycle (SDLC)
  • How to manage yourself and avoid common pitfalls that challenge many leaders
  • How to manage multiple teams and learn how to manage managers
  • Proven tactics to deliver better customer experience every time, even in fast paced environments

Released September 30, 2020

Subscribe to the mailing list to stay up to date

© 2020 Hashtag Coder
Built with Gatsby