Show newer

@aescling @monorail yes all of this is valid but polluting the global namespace is the most important code smell

@vaporeon_ never mind I took some tylenol and my autism came back

re: wrong 

@vaporeon_ @monorail in javascript functions can be reassigned

so lets say you work on a web site for your company that uses old-ass ES5 javascript because it was first made in 2009 and its for a government contractor who won't fund what is necessary for your team to change to a newer javascript workflow, so you're stuck with it

In one file, a coworker who no longer works at the company 10 years ago created a function called gorp like so: function gorp() { /* whatever gorp does */}

Now, today you are working on a file that has a function called girp and you reassign it something else. However, you make a typo and write gorp instead. This does not throw at runtime because gorp is global, and now you have bugs that are extremely difficult to decipher because you didn't notice a typo

@vaporeon_ @monorail if my web page loaded two javascript files, (lets call them one.js and two.js)

and one.js defines a function

function globalFunc() {
console.log('I am global');
}

then two.js can use that function

@monorail this doesn't work in node.js for whatever reason, shittyRandom1 is not added to global scope

@monorail function declarations create global variables because javascript sucks

@monorail also, reported a second time for using a function declaration

Somebody immediately liking and boosting my toots will fix me

@lapis I've done enough at this point to where that won't be necessary, but I will use this wisdom in the future

@lapis I finished the driving and got all of the boxes in the house! But now I need to carry things up the stairs 😵‍💫

Show older
📟🐱 GlitchCat

A small, community‐oriented Mastodon‐compatible Fediverse (GlitchSoc) instance managed as a joint venture between the cat and KIBI families.