- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
"strDate, as the name implies, is a date. "
Or perhaps it's a string.
Admin
Looks like a broken event pipeline as well. A->B->C instead of A->B, A->C
In JS people have a really bad habit of putting stuff on the DOM, specifically parts of the DOM intended for layout, rendering, structure, HTML, view, etc and then having other things read it back.
Attaching data to the DOM isn't always bad, it's a mixed bag but should be done unobtrusively.
It's wonderful to see things such as...
Data can weave through an application like a giant snake, often being picked out at random. For reference the appropriate practice is:
data_model.* -> intl.format -> document_model.view
You'll also see worse in practice. A lot of <-> as in (model <-> view):
The unformat is always just a guess like turn comma to period, remove whitespace and weird characters then hope for the best making things even worse.
There's almost never a reason to use on especially if you have access to JS. Instead you use classes, ids and data attributes to allow behaviour to be attached. Often people do things like data.onsomething in JS when the on attributes are only meant to be used for HTML. Because in JS you don't need it, you have addEventListener.
It could be worse. Imagine someone put all their JS entirely in on tags, when the entire initial JS in onload.
Admin
Get ready for the script treatments!
http://bit.ly/2oUvlYl
Admin
Or, perhaps, a boolean to track whether a string is parsable into a date or whether a date has been converted to a string?
Admin
So... prototype.js or something homegrown?
Admin
All those people who say "strDate" must be a date get really confused when they go to Seattle's Best Coffee and find it isn't.
Admin
http://bit.ly/2FsnYO3
Admin
Google === 0 :)
http://bit.ly/2FsnYO3
Admin
Someone saw jQuery, thought it was a good idea, and decided to reinvent it.
Admin
But what does GetInnerFunction do!
Admin
By the name of it, it gets the Inner Function :) LOL
Admin
Or perhaps it is the name of someone you saw on Tinder…
Admin
"strDate, as the name implies, is a string holding a date." good save!
Admin
It's just that before jQuery became mainstream,
$
was actually widely used as a shorthand alias fordocument.getElementById
.Admin
Both prototype.js and mootools used the single $ for that purpose. $$ was closer to the "jQuery" syntax, at least for CSS selectors.
Admin
You're not wrong, and it's good to point these things out, but ultimately you're appealing to aesthetics. If you're ever designing a framework, just ban this stuff because most coders have no sense of aesthetics and will just cram stuff anywhere they can.
Admin
This. Especially in the early days of jQuery (and still to some extend), it's a massive resource hog which is completely unnecessary for the vast majority of sites that use it. A few short-hand functions like the $ thing would usually be all you needed; back in the day we had a standard set of functions (I'd hardly call it a library) which was in its non-minified form maybe a hundred lines or so, which sufficed for all the basic stuff we would otherwise use jQuery for.
If you think that doesn't matter, try loading one of those websites that liberally spray JS libraries all over the place on an older smartphone (or heck, even an older computer) and enjoy the page jumping around as it goes through all the recursive parsing that occurs. It's almost as unusable as those sites that think they need to re-invent the scrollbar.
Admin
no! it's a struct! ansi c has struct tm to represent dates, this is it!
Admin
Even simply calling
obj.onFocus()
directly would at least setthis
correctly...Addendum 2018-03-14 08:03: Sorry I mean
objElement.onFocus()
of course.Admin
if ("th" + "is !== "this") return "WTF";