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]
arr.length = 3
arr.length = 0
I tweet about this type of thing a lot. If you enjoyed this article, you may enjoy following me.
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