3 ms·
Here are some reasons why JS sucks. - Global variables by default, which means you will have "var" sprinkled everywhere. - Brain-dead binding. function C
by codexon 16y ago
Here are some reasons why JS sucks.
- Global variables by default, which means you will have "var" sprinkled everywhere.
- Brain-dead binding.
function Constructor() {
this.foo = 'bar';
var that = this;
window.setTimeout(function() {
alert(that.foo);
}, 1);
}
- You can call a function with less arguments than specified, meaning you potentially have to make sure each argument is not "undefined" .
- Somehow JS isn't weakly typed when it comes to switch statements.
a = 5;
b = '5';
if( a == b )
alert("Equal");
switch (a) {
case b:
alert("This never shows");
}
I am fairly certain that JS popularity is mostly in part due to its monopoly on the web. I'm sure there are more experienced JS users who can point out more flaws.
- Kilimanjaro 16y agoSorry pal, if you write spaghetti code JS will bite you in the butt, but I've been coding for 20 years and I'm used to declare everything before using it and to be very careful when choosing names for my stuff and never do silly equalities. So no, I've never encountered such problems.
- codexon 16y agoPal, please learn how to read carefully. Nowhere did I complain about needing to declare things before using it. Having variables be global by default is really poor design. And about silly equalities, it will inevitably happen once your programs get bigger, and you become frustrated with a bug that has been suppressed through multiple function calls because Brendon Eich thought weak typing was a good idea.
- orangecat 16y agoYes, and I'm sure you never have memory management problems in C and are an above average driver. But for the mere mortals who occupy most development positions, having behavior silently and radically change when you forget a "var" is not a good thing.