JavaScript Nehronical

After reading this translation of the April Fools' Day article on JavaScript, I was surprised at what little things people can find fault with. And the problem is not in the article itself, not in memes and jokes about this language, but in the fact that someone neironically claims that JavaScript is a bad programming language. But what if you try to understand him?


Answer the question, if you are developing on JS, then what exactly? Maybe you are working on FrontEnd, maybe you are developing a small BackEnd application on nodejs, or maybe you are a developer in a bank where all the software is written on it? If the third case is about you, then most likely you were mistaken somewhere.


The problem is that not a single programming language can become a panacea for using different PLs to achieve certain goals. But for some reason, someone still believes that some language will replace all existing ones, become universal and generally save the whole world. But usually tools are created to solve specific problems (even though the word "specific" can include a rather extensive range of these very tasks), and even a Swiss knife will not solve all your problems.


JavaScript does a good job of the tasks for which it is most often used. And most of the loose cases that were considered in the above article are spherical horses in a vacuum and simply will not be used in real development.


First of all, I would like to give the following code snippet as an example:


const x={
  i: 1,
  toString: function(){
    return this.i++;
  }
}

if(x==1 && x==2 && x==3){
  document.write("This will be printed!")
}

, . โ€” ยซ?!ยป ยซ ?ยป. . . JavaScript โ€” . โ€” (===) (==). , . () . - `x == 1 && x == 2 && x == 3` - , , :


public class JavaScript {
	public static void main(String[] args) {
		AnonymousObject x = new AnonymousObject(1);

		if (x.equals(new AnonymousObject(1)) && x.equals(new AnonymousObject(2)) && x.equals(new AnonymousObject(3))) {
			System.out.println("JavaScript == Java // true");
		}
	}
}

class AnonymousObject {
	public int i;

	public AnonymousObject(int i) {
		this.i = i;
	}

	public boolean equals(AnonymousObject that) {
		return this.i++ == that.i;
	}
}

- .equals(), .toString(), , .toString() , . JS , Java .


.sort(), :


[-2, -7, 0.0000001, 0.0000000006, 6, 10].sort()
// [-2, -7, 10, 1e-7, 6, 6e-10]

:


[-2, -7, 0.0000001, 0.0000000006, 6, 10].sort((a, b) => a - b)
// [-7, -2, 6e-10, 1e-7, 6, 10]

- , < > , . , , . - , ?!


JS. , JavaScript- , - - , โ€” web . , / / . - . , - . nodejs, : comlink, paralleljs, . , . .


, , . - , , . , :


: , , , .


UPD:

:


1. , , , , . , - , ,


2. , JS , . , . JS, , , - . JS , . ,


All Articles