DEV Community

loading...
Cover image for πŸš€ Get better at web development: CodeSnacks 🍫πŸͺ🍩 Tutorial Tuesday Newsletter + one sweet JS hack!

πŸš€ Get better at web development: CodeSnacks 🍫πŸͺ🍩 Tutorial Tuesday Newsletter + one sweet JS hack!

Benjamin Mock
I'm Ben, a Frontend Developer from Germany working at ebay
・2 min read

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

Discussion (2)

Collapse
diegomgar profile image
Dieg Oto

Subscribed! Let's train! :D

Collapse
benjaminmock profile image
Benjamin Mock Author

Awesome! Thank you!