Bristol JS

A friendly JavaScript group in the lovely city of Bristol

233

Members

29

Events

🎉 Join community

Tags

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

Sponsors

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.

Give credit when pairing

When you are pairing sometimes only the host gets credited for praise/blame with pairing commits.

Today I learned that you can add a co-author:

git commit -m "Commit description
>
>
Co-authored-by: John Smith <john.smith@acme.inc>"

Just add 2 blank lines then the co-author message in.

It will be shown like this in GitHub:

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.

Bonus:

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

console.log(myArray)
// [1,2,4,8]

Subscribe to our newsletter

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

© 2021 TechTalks.io Limited. All rights reserved.