Teddi Mellencamp finally breaks her silence on the affair that ended her marriage: 'There was somebody else'
CodeSOD: Device Detection
There are a lot of cases where the submission is "this was server side generated JavaScript and they were loading constants". Which, honestly, is a WTF, but it isn't interesting code. Things like this:
if (false === true) { // do stuff }That's absolutely the wrong way to do that, and I hate it, but there's just so many times you can say, "send server-side values to the client as an object, not inline".
But Daniel's electrical provider decided to come up with an example of this that really takes it to the next level of grossness.
var isMobile = "" === "true"; var isAndroid = "" === "true"; var isIPad = "" === "true"; var isIPhone = "" === "true";For starters, they're doing device detection on the server side, which isn't the worst possible idea, but it means they're relying on header fields or worse: the user agent string. Maybe they're checking the device resolution. The fact that they're naming specific devices instead of browser capabilities hints at a terrible hackjob of reactive webdesign- likely someone wrote a bunch of JavaScript that alters the desktop stylesheet to cram the desktop site onto a mobile device. But that's just background noise.
Look at that code.
First, we've got some lovely order-of-operations abuse: === has higher precedence than =, which makes sense but hardly makes this code readable. The first time I saw this, my brain wanted the assignment to happen first.
But what's really special to me is the insistence on making this stringly typed. They control both sides of the code, so they could have just done booleans on both sides. And sure, there's a world where they're just dumb, or didn't trust their templating engine to handle that well.
I've seen enough bad code, though, to have a different suspicion. I can't confirm it, but c'mon, you know in your hearts this is true: the function which is doing device detection returns a string itself, and that string isn't always a boolean for some reason. So they needed to wrap the output in quotes, because that was the only way to make sure that the JavaScript actually could be executed without a syntax error.
I can't be sure that's true from this little snippet. But look at this code, and tell me that someone didn't make that mistake.
.comment { border: none; }From the street it looks like a humble shack - but there's a very good reason why locals are in awe of this 'breathtaking' Tasmanian home
The London underground station used by thousands of Essex commuters each day built on site of infamous asylum and plague pit
I peeled an onion and ended up in the emergency room in serious trouble - and it can happen to anybody
Nigel Farage's Reform UK overtakes Labour to top polling for the first time - while winning support of one in four who voted Conservative last time
Eight photos of Manningtree restaurant's auction dinner which raised over £3,000
Boss of store hit by car in smash which killed Essex Uni students pays tribute
Teenage boy left with facial cuts after attempted robbery in Colchester
Historic 16th century house with 1.3 acres of gardens up for sale near Braintree
Boss of store hit by car in smash which killed Essex Uni students pays tribute
Salesforce Cutting 1,000 Roles While Hiring Salespeople for AI
Read more of this story at Slashdot.
Fans praise 'classy' Kim Kardashian for showing naked Bianca Censori how to dress properly after Grammys mess
Insiders reveal how JD Vance is navigating a 'unique' relationship with Trump… and their shared trait
Trump scrubs all mention of DEI, gender, climate change from federal websites
Vast numbers of webpages have disappeared from federal sites in an effort to meet the deadline to implement the Trump administration's executive orders targeting diversity initiatives and gender.…
CERN's Mark Thomson: AI To Revolutionize Fundamental Physics
Read more of this story at Slashdot.