https://StartupHakk.com/?v=EKLVV3rJSfg
#coding #codingbootcamp #softwaredeveloper #codeyourfuture
GitHub Repo: https://github.com/slthomason/Startup...
I’ve seen a lot of folks using the term “attribute’ interchangeably between HTML and JavaScript the past year. Some of it stems from a garbage translation layer/ruleset doing so, but on the whole it reeks of utter ignorance to say they are the same thing.
This is even more true when one considers the number of Object properties (and getters) that don’t have HTML equivalents, or perform processing on the data. Element.dataset for example is NOT an HTML attribute, it’s a property of the Element object prototype.
And yes, PROPERTY. Can we at least agree on the basic terminology?
Attribute —the key in a key/value pair used on a tag in a markup language
Property — A variable that’s attached to an object.
Method — A function that’s attached to an object.
Getter & Setter —Methods that behave like properies
If you are calling them something other than that or using them interchangeably, you’re talking out your arse!
Probably the best example of this can be found in the difference between all the different ways of getting an HTMLInputElement’s value and default.
HTMLInputElement.getAttribute(“defaultValue”) returns null because defaultValue is not an HTML attribute! It’s a JavaScript property of the HTMLInputElement object! You can see that HTMLInputElement.value returns the current value, and HTMLInputElement.defaultValue returns what it was set to in the markup… and that’s the fun because getAttribute returns the same thing as defaultValue. The current input.value does not equal the attribute as declared in the markup!
I’ve lost count of the number of times I’ve seen people not only claim that HTML attributes and DOM properties are the same thing, and have code go bits-up face-down because of that ridiculously ignorant claim. There is a reason setAttribute and getAttribute exist on DOM Elements separate from their Element property equivalents.
It’s easy to get this confused such as with Element.className, since it’s a getter/setter arrangement that DOES change the attribute. The inconsistency of behavior can — for those not versed well in the terminology or what objects are / are for — lead to this misunderstanding.
Bottom line though, if it’s on the DOM in a JavaScript object, it’s not an “attribute” anymore, stop saying that!
Lots of Great How Tos and Code Samples! Make sure to like and subscribe!
На этой странице сайта вы можете посмотреть видео онлайн The Difference Between HTML Attributes and JavaScript Object Properties | HOW TO - Code Samples длительностью часов минут секунд в хорошем качестве, которое загрузил пользователь STARTUP HAKK 01 Сентябрь 2023, поделитесь ссылкой с друзьями и знакомыми, на youtube это видео уже посмотрели 74 раз и оно понравилось 0 зрителям. Приятного просмотра!