DEV Community

Cover image for 16th weekly post, slice and map. Also, Jest.
LongYC
LongYC

Posted on • Edited on

1

16th weekly post, slice and map. Also, Jest.

Items of the week

  1. JavaScript - the array .slice() method accepts negative index, thus it is possible to extract the last element with .slice(0, -1). More details available on MDN Web Docs.

  2. JavaScript - it is common to see objects being used as maps but there are quite a number of differences in using an actual Map, such as using any types as keys instead of just string. MDN Web Docs has a good comparison table on this.

  3. Jest - ESM support is still experimental at the moment as mentioned in the official documentation page.

Note of the week

On the week 43 of 2021, we saw that the news of the upcoming Firefox 94 switching from GLX to EGL, this should translate to better WebGL performance for Linux users. That's all for this week's post, I must admit this week's post was a bit more rushed than usual, still, thank you for reading and if you have got any feedback, do let me know by leaving a comment. Have a nice day!

Top comments (0)

11 Tips That Make You a Better Typescript Programmer

typescript

1 Think in {Set}

Type is an everyday concept to programmers, but it’s surprisingly difficult to define it succinctly. I find it helpful to use Set as a conceptual model instead.

#2 Understand declared type and narrowed type

One extremely powerful typescript feature is automatic type narrowing based on control flow. This means a variable has two types associated with it at any specific point of code location: a declaration type and a narrowed type.

#3 Use discriminated union instead of optional fields

...

Read the whole post now!