tldr: πππsubscribe to my web development newsletter and let's grow our skills as developers together!
13 is my lucky number. And this is my 13th article in my codesnacks series. So I hope I'm lucky and you forgive me for some self-promotion.
I write a couple of tutorials each week - mostly about JavaScript but also about web development in general.
Currently, it's mostly vanilla JS content but it will also be about React, Vue, Node.js, Svelte, or other topics. Primarily I write snackable content.
I try to communicate one specific idea or one trick I learned in less than 5 minutes, hence the name codesnacks.
If you'd like to receive a small newsletter every week with my tutorials and other stuff I liked, then please subscribe to my Tutorial Tuesday newsletter.
It will contain stuff like this:
π‘ Dealing with command line arguments in Node.js
Learn how to read command-line arguments in Node.js.
Coercion in JavaScript - π€ do you know what it is?
Learn about coercion - implicit and explicit. Which methods use coercion and what the implications are.
const π¦, seal π€, freeze βοΈ & immutability π€ in JS
Learn about the Object.seal and Object.freeze method, their limitations and what distinguishes them from immutability
As a small thank-you I'd like to share one little hack with you to access the last element of an array:
So instead of doing it like this
const arr = [1, 2, 3]
const lastElement = arr[arr.length - 1]
You can also use slice
and pop
.
const arr = [1, 2, 3]
const lastElement = arr.slice(-1).pop()
You might ask why you want to use this syntax. Well, you don't need to save your array to a variable this way.
Let's say we want to get the last link of a webpage. You could do it like this, without saving the list of links into an additional array:
Array.from(document.querySelectorAll("a")).slice(-1).pop()
Want to get better at Web Development?
πππsubscribe to the Tutorial Tuesday βοΈnewsletter
Top comments (2)
Subscribed! Let's train! :D
Awesome! Thank you!