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...
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 :)
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!
For further actions, you may consider blocking this person and/or reporting abuse
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 hereLibraries?... 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 todocument.querySelector
, you would create another function asqsa
as a shortcut todocument.querySelectorAll
, and so on...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 :)
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!