Police appeal as Essex man missing for 7 days-have you seen him?
I'm a Celeb fame Stacey Solomon shares new life update with fans
Fundraiser started for boy, 11, who died after GP told him he had 'just a virus'
Major disruption on all Greater Anglia trains to and from London Stansted Airport
Oasis support artist announced as headliner for Summer Series gig
Listed: Best 'cheap eats' Essex restaurants named among top in the country
Successful indie-pop band announced as next Essex Summer Series headliner
£110 million 'giga mansion' in Belgrave Square will become one of London's most expensive homes - with global billionaires targeted as most likely buyers
CodeSOD: Copied Homework
Part of the "fun" of JavaScript is dealing with code which comes from before sensible features existed. For example, if you wanted to clone an object in JavaScript, circa 2013, that was a wheel you needed to invent for yourself, as this StackOverflow thread highlights.
There are now better options, and you'd think that people would use them. However, the only thing more "fun" than dealing with code that hasn't caught up with the times is dealing with developers who haven't, and still insist on writing their own versions of standard methods.
const objectReplace = (oldObject, newObject) => { let keys = Object.keys(newObject) try { for (let key of keys) { oldObject[key] = newObject[key] } } catch (err) { console.log(err, oldObject) } return oldObject }It's worth noting that Object.entries returns an array containing both the keys and values, which would be a more sensible for this operation, but then again, if we're talking about using correct functions, Object.assign would replace this function.
There's no need to handle errors here, as nothing about this assignment should throw an exception.
The thing that really irks me about this though is that it pretends to be functional (in the programming idiom sense) by returning the newly modified value, but it's also just changing that value in place because it's a reference. So it has side effects, in a technical sense (changing the value of its input parameters) while pretending not to. Now, I probably shouldn't get too hung up on that, because that's also exactly how Object.assign behaves, but dammit, I'm going to be bothered by it anyway. If you're going to reinvent the wheel, either make one that's substantially worse, or fix the problems with the existing wheel.
In any case, the real WTF here is that this function is buried deep in a 15,000 line file, written by an offshore contract team, and there are at least 5 other versions of this function, all with slightly different names, but all basically doing the same thing, because everyone on the team is just copy/pasting until they get enough code to submit a pull request.
Our submitter wonders, "Is there a way to train an AI to not let people type this?"
No, there isn't. You can try rolling that boulder up a hill, but it'll always roll right back down. Always and forever, people are going to write bad code.
Suspected Lakeside robber accused of stealing more than £30,000 worth of iPhone 17s
Man charged with drug offences after Essex police stop and search car
Family of missing Colchester sailor find burnt devices as search continues
'Fast-moving and large' police probe launched after string of Essex robberies
'Shed' for sale for £225,000: Estate agents say one-bed property at bottom of garden is 'stylish detached home'
JO ELVIN: 'I'm a 50-year-old K-pop addict.' As Netflix's K-pop film becomes its most-watched ever, here's why I'm obsessed
HPC Is Not Just Riding The Coattails Of AI
The cluster architectures for AI training and inference are driving unprecedented growth in the datacenter infrastructure spending, but they are also having a reflective and beneficial impact on HPC architectures thanks to the relative ease with which one can get funding for AI initiatives and the need to upgrade existing HPC systems to do traditional simulation and modeling. …
HPC Is Not Just Riding The Coattails Of AI was written by Timothy Prickett Morgan at The Next Platform.
If The GenAI Bubble Bursts, Nvidia Will Still Keep Growing
Here’s a riddle for you: What’s the difference between an economic bubble and an economic transformation? …
If The GenAI Bubble Bursts, Nvidia Will Still Keep Growing was written by Timothy Prickett Morgan at The Next Platform.