Тёмный

STOP Declaring IDs!?! JavaScript Global Variables Best Practices 

codeSTACKr
Подписаться 296 тыс.
Просмотров 15 тыс.
50% 1

🦸 Become A VS Code SuperHero Today: vsCodeHero.com
🧑🏾🤝🧑🏽 Join my Discord developer community: / discord
Did you know that you don't have to use getElementById() or querySelector() to access a DOM element that has an HTML ID?
HTML element IDs are accessible as global variables on the window object.
So, should we stop using `getElementById()` and `querySelector()`?
NO
Even though this does seem to be a convenient way to write a little less code, it should not be used.
It's always good practice to declare your variables.
_____________________________________
🚢 Deploy for FREE on Vercel: vercel.com/amb...
📚 FREE 7-Day trial at Treehouse: treehouse.7eer...
_____________________________________
🛠️ Tools I use:
🟠 codeSTACKr Theme: marketplace.vi...
🟠 STACKr Code Font (Exclusive to my VS Code Course - vsCodeHero.com)
🟠 SuperHero Extension Pack: marketplace.vi...
_____________________________________
💖 Show support!
PayPal: paypal.me/code...
_____________________________________
👀 Watch Next:
Playlist: Web Development For Beginners - • Web Development - Begi...
_____________________________________
🌐 Connect With Me:
Website: www.codestackr...
Twitter: / codestackr
Instagram: / codestackr
Facebook: / codestackr
_____________________________________
** Affiliate Disclaimer: Some of the above links may be affiliate links, which may generate me a sales commission at no additional cost to you.
#codeSTACKr #JavaScript #learntocode

Опубликовано:

 

15 сен 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 72   
@codeSTACKr
@codeSTACKr 3 года назад
🦸 Become A VS Code SuperHero Today: vsCodeHero.com 🧑🏾‍🤝‍🧑🏽 Join my Discord developer community: discord.gg/A9CnsVzzkZ
@StarcoreLabs
@StarcoreLabs 3 года назад
I've always used Classes for CSS and unique ID's for JavaScript. It makes my code cleaner and easier to maintain.
@codeSTACKr
@codeSTACKr 3 года назад
That's the best way to go about it!
@marshwiggleme
@marshwiggleme 2 года назад
Me too, although I've only just started JS. Classes for most things, IDs for labels and functionality.
@beinyourguard
@beinyourguard 3 года назад
this feature is way more dangerous than helpful
@codeSTACKr
@codeSTACKr 3 года назад
I totally agree!
@ziaahmad8738
@ziaahmad8738 3 года назад
i didnt knew about this, thanks a lot
@IkraamDev
@IkraamDev 3 года назад
PLEASE keep doing more update videos like this!
@jp46614
@jp46614 3 года назад
I never knew this was a thing! Thanks for letting us know, it looked like a bad idea from the moment you started the demonstration. It also shows how much browsers are divided and how much consideration you have to put into JavaScript code without using something like Babel to run on most/all browsers.
@codeSTACKr
@codeSTACKr 3 года назад
Totally agree :)
@JawadKhan-gc6du
@JawadKhan-gc6du 3 года назад
Loved the quality video. Short , informative and very much useful. Thanks codeSTACKr
@codeSTACKr
@codeSTACKr 3 года назад
Glad you liked it!
@DThompsonDev
@DThompsonDev 3 года назад
When I first saw this I just imagined all the ways someone can mess up and confuse a codebase lol. Cool thing but I agree with you, people shouldn't be using it.
@codeSTACKr
@codeSTACKr 3 года назад
For sure! Throw one into your next work project and confuse everyone 😂 (Please don't!)
@thiyageshkanna
@thiyageshkanna 3 года назад
very informative. I was fasinated when you explain this stuff .Thank you so much for the explanation
@codeSTACKr
@codeSTACKr 3 года назад
Glad it was helpful!
@salmanmurtaza2889
@salmanmurtaza2889 3 года назад
This is an excellent tutorial. create a video on defining the DOM in depth and how to access and manipulate it in Javascript because all we know "DOM is the programmatic representation of a web page and what we see in the browser is the visual representation of the DOM" and there aren't in depth tutorials about explaining the DOM
@uchechukwuprincenwulu2026
@uchechukwuprincenwulu2026 3 года назад
Thank you for this info. Very informative incase we run into such use cases on open source libraries/code samples
@GeorgeMonsour
@GeorgeMonsour 3 года назад
Thanks for this great direction and caution because not enough of it being conveyed.
@aniruddharora4004
@aniruddharora4004 3 года назад
Love these vids, any new info is good info👍
@codeSTACKr
@codeSTACKr 3 года назад
Glad to hear!
@MohidulIslam-el8fd
@MohidulIslam-el8fd 2 года назад
Sir I don’t know english properly. Plz tell me what is the best practice ? Using getElementById() is the best practice ??
@shybrown6964
@shybrown6964 3 года назад
Hey bro your new subscriber from Bangladesh.
@codeSTACKr
@codeSTACKr 3 года назад
Welcome!
@francescociulla
@francescociulla 3 года назад
Great video 🔥
@codeSTACKr
@codeSTACKr 3 года назад
Thanks so much!!
@danielbark
@danielbark 3 года назад
Nicely laid out sir!!
@codeSTACKr
@codeSTACKr 3 года назад
Glad you liked it!
@kaloianlawless7246
@kaloianlawless7246 3 года назад
Very well explained and informative video! Thank you man! =)
@codeSTACKr
@codeSTACKr 3 года назад
Glad it was helpful!
@vuelancer
@vuelancer 3 года назад
I made a video on my channel "Vuelancer" using this exact thing. It's a great feature!
@suryam_29
@suryam_29 3 года назад
wow , long time confusion comes clear. i don't like to use getElementById but, now i understood the use of it. please make a video on clean code codestackr.......
@prudhvichinnam1488
@prudhvichinnam1488 3 года назад
I want Css mini projects like dropdown menu please do this for beginners
@vinitchuri9729
@vinitchuri9729 3 года назад
There is already one on this channel
@justlutfi2890
@justlutfi2890 3 года назад
bootstrap
@judyodiakose6838
@judyodiakose6838 Год назад
What about using data attr to select elements in JavaScript
@thatsalot3577
@thatsalot3577 2 года назад
how is your editor so smooth does that has something to do with the extension or it's your monitor.
@zerosandones7547
@zerosandones7547 2 года назад
How did you make your vscode so smooth? Is it in the settings, or is it an extension? WOW
@CodingJourney
@CodingJourney 3 года назад
Mind-blowing 🙂 Thanks for sharing 💙💙
@teodygirado9982
@teodygirado9982 3 года назад
omgg this is huge thanks mate
@malikrajat
@malikrajat 3 года назад
Well, very intresting. Thank for such useful and unique content
@LouayDeeb
@LouayDeeb Год назад
Wonderful
@saunaknandi1814
@saunaknandi1814 3 года назад
what is ur vscode setting for this color and writing style
@altonmichaux5824
@altonmichaux5824 3 года назад
Very interesting, thanks!
@iUmerFarooq
@iUmerFarooq 3 года назад
Thanks to share this cool Tip 👌
@rau8928
@rau8928 3 года назад
Nice, I always thought it was a bug
@albirtarsha5370
@albirtarsha5370 3 года назад
I am not yet buying this argument for never using ids for styling only. I think there are semantic arguments to be made in favor of using id sometimes.
@Me-vc4sf
@Me-vc4sf Год назад
It should be removed causing a lots of problems in one of my framework.....we should be able choose whether to declare this type of Dom elements as global object or not
@khangtran938
@khangtran938 3 года назад
How can I make my cusor with animation like that? I also use vim for vscode. Thanks!
@rangabharath4253
@rangabharath4253 3 года назад
awesome as always :-)
@codeSTACKr
@codeSTACKr 3 года назад
Thanks again!
@zubayerhossain7074
@zubayerhossain7074 3 года назад
Which color theme do you used in vs code?
@codeSTACKr
@codeSTACKr 3 года назад
My codeSTACKr Theme :) marketplace.visualstudio.com/items?itemName=codestackr.codestackr-theme
@ayoubyahiaoui2071
@ayoubyahiaoui2071 3 года назад
Hi, please what extension are u using for Vscode
@codeSTACKr
@codeSTACKr 3 года назад
My extensions, theme, and font are in the description :)
@yt-sh
@yt-sh 3 года назад
didnt know that
@nikheelpatel3478
@nikheelpatel3478 3 года назад
Noone : calling getElementById() is annoying. Literally No one: Chrome is using less memory. Developers: Let's make every element with Id global.😎 NO ONE CARES ABOUT MEMORY.
@SirXtC
@SirXtC 3 года назад
so basically we are better off not know this... got it lol
@robertkaminski1781
@robertkaminski1781 3 года назад
this light reflections in your eyes are weird
@nagendradevara1
@nagendradevara1 3 года назад
🤯
@paulosilva-dm1qb
@paulosilva-dm1qb Год назад
AI..Generated content..But I liked it.
@SebastianPerezG
@SebastianPerezG 3 года назад
Same id on multiple elements is a bad practice.
@codeSTACKr
@codeSTACKr 3 года назад
Exactly! Don't do it!!
@thecscontent5110
@thecscontent5110 3 года назад
I also do videos about programming!😁
@TheShmrsh
@TheShmrsh Год назад
DOESNT WORK!
@zxenon_
@zxenon_ 3 года назад
Terrible🤦‍♂️. Another reason again, for devs who don't like Js...
Далее
5 JavaScript Concepts You HAVE TO KNOW
9:38
Просмотров 1,4 млн
Vibes in Ney York🗽❤️! #shorts
00:26
Просмотров 21 млн
Top 10 Best VS Code Extensions
17:37
Просмотров 1 млн
JavaScript Memory Leaks and How To Fix Them
14:58
Просмотров 26 тыс.
as const: the most underrated TypeScript feature
5:38
Просмотров 118 тыс.
This VS Code AI Coding Assistant Is A Game Changer!
14:27
Junior Vs Senior Code - How To Write Better Code
22:13
Learn JavaScript Scoping In 10 Minutes
11:39
Просмотров 61 тыс.