Javascript is often horrifying, but it's also sort of refreshing to work in a dynamic language again.

· · Web · 3 · 2 · 6

For example, a library I'm using didn't do a thing the way I wanted. No problem - just patch in the way I wanted it to work by replacing the functions on the object's prototype... Swizzling ftw.

I'm sure there's no possible way this will bite me in the ass later.

@bigzaphod my colleague made a thing so you can add the diff you want to apply to that library in your git repo, and then apply that diff automatically when installing dependencies:

@bigzaphod Me: "Let me do some of these math calculations in the web UI in JavaScript I'm sure it will be fine."

Me 5 minutes later: "Well that was my dumbest idea ever."

@bigzaphod If you're not doing horrifying things with a language's type system, are you even programming?

@bigzaphod This is where someone says something smug about Lisp.

@bigzaphod I do a lot of work with dates, this has been a life-saver:

Date.prototype.stdTimezoneOffset = function() {
var jan = new Date(this.getFullYear(), 0, 1);
var jun = new Date(this.getFullYear(), 6, 1);
return Math.max(jan.getTimezoneOffset(), jul.getTimezoneOffset());

Date.prototype.isDstObserved = function() {
return this.getTimeZoneOffset() < this.stdTimezoneOffset();

Added an easy check to the Date method to check if the location observes DST. Super handy!

@ashfurrow oh wow.. that's brilliant and awful at the same time.

@bigzaphod I do miss that in Swift. Not enough to use JavaScript though 👻

@GeekAndDad ES6 really isn't just too bad now that it has a real class syntax and whatnot. I mean, it's still all dynamic and SUPER easy to shoot yourself in the foot.. but.. not as much.

@bigzaphod @GeekAndDad And, running eslint will find most of the problems static types and compiling would. Atom'll run it automatically.

@bigzaphod does it still have three or four kinds of true & false?

@GeekAndDad yeah... unfortunately. Using === seems to avoid the problem.

Sign in to participate in the conversation

Server run by the main developers of the project 🐘 It is not focused on any particular niche interest - everyone is welcome as long as you follow our code of conduct!