Bristol JS

A friendly JavaScript group in the lovely city of Bristol





🎉 Join community


JavaScript Node.js React Angular Vue.js Front-end Back-end


What are TIL's?

TIL • acronym • Today I Learned

TIL stands for Today I Learned... it's a place to share knowledge, tips and tricks with other members in your community. Snippets are up to 1500 characters.

Debug an element by adding an ID of "test"

TIL thanks to a tweet from Devon Govett...

If you add an ID of "test" to an element:

<div id="test"></div>

You can access it using the global variable test from JS from the console. Could be handy for debugging.


Also, incase you dind't know, any highlighted selected in the "Elements" tab of developer tools can be accessed directly in the console with $0.

🐛 Happy debugging!

Truncate an Array by setting its length

Today I Learned that in JavaScript an Array can be truncated by simply setting its length 🤯

Here is an example:

const myArray = [1, 2, 4, 8, 16, 32, 64, 128]
myArray.length = 4

// [1,2,4,8]

Subscribe to our newsletter

No spam. Just simple and infrequent platform updates when something big happens.

© 2020 Limited. All rights reserved.