CodeNewbie Community 🌱

Discussion on: From Front Desk to Front End p5 Beginning Javascript

Collapse
 
dennistobar profile image
Dennis Tobar

The querySelector could return null, but you could use ?. when the next function or parameter is not expected to be null (and it's ok with that). A full descriptive article is here

Libraries?... I suggest if you use the same functions every time, everywhere, you can write a few functions as helpers to make the development in Javascript easier -and friendly.

For example, I said qs as a shortcut to document.querySelector, you would create another function as qsa as a shortcut to document.querySelectorAll, and so on...

let qs = (selector) => document.querySelector(selector);
let qsa = (selector) => document.querySelectorAll(selector)
Enter fullscreen mode Exit fullscreen mode

If you feel lost, don't be afraid; in the next chapters or parts of your course, you will learn about functions and how to improve the readability of your javascript :)

Image description

Thread Thread
 
taurist profile image
Tauri StClaire

Thank you for elaborating @dennistobar! We're still going over functions a lot, so I'm going to focus on my lessons first then certainly come back to what you're saying bc I'm all for saving time!