# less_retarded_wiki

main page, file list (652), source, commit RSS feed, report abuse, stats, random article, consoomer version

# JavaScript

Not to be confused with Java.

JavaScript (JS) is a very popular, highly shitty bloated scripting programming language used mainly on the web. The language is basically the centerpoint of web development, possibly the worst area a programmer can find himself in, so it is responsible for a great number of suicides, the language is infamously surrounded by a clusterfuck of most toxic frameworks you can imagine and a curious fact is also that people who program in JavaScript are less intelligent than people who don't program at all. JavaScript is NOT to be confused with an unrelated language called Java, which for some time used to be used on the web too but works very differently. JavaScript should also not be confused with ECMAScript, a language standard which JavaScript is based on but to which it adds yet more antifeatures, i.e. JavaScript is a dialect of ECMAScript (other similar ECMAScript-based languages are e.g. ActionScript and JScript). By now it's a common knowledge that JavaScript is used exclusively to implement antifeatures such DRM, cryptominers, spyware, bloat, ads and CO2 increasers (YouTube started to artificially throttle the CPU of browsers with adblocks to punish them). LRS stance towards this language is clear: as any other mainstream modern language JavaScript is an absolutely unacceptable choice for any serious project, though it may be used for quick experiments and ugly temporary programs as the language is high level, i.e. extremely easy, it doesn't require any ability to think, it works in every browser (so you get a kind of multiplatformness) and allows making things such as GUI and visualizations super quickly and easily. But remember that this kind of "comfort" always comes for a cost too high to pay.

How bloated is JavaScript? Very much. A MINIMALIST C implementation called QuickJS has around 80K lines of code -- compare e.g. to about 25K for tcc, a similar style implementation of C, and about 5K for comun. A more mainstream implementation of JavaScript, the v8 engine (used e.g. in node.js) has over 1 million lines of code of C++. { Checked with cloc. V8 also contains web assembly aside from JavaScript, but still you get the idea. ~drummyfish }

In summary, here is what we can thank JavaScript for:

- Only the richest corporations can now make a web browser.
- Websites can't be indexed, download or archived.
- Websites can spy on you.
- Websites can mine crypto on your computer.
- Websites burn more CO2.
- Websites automatically download and run arbitrary code on your computer without asking.
- Old computers can no longer browse the web.
- The Web is bloated, slow and ugly.
- The Web is dead.
- Websites can refuse to display the content if you have adblock.
- Websites can automatically open pop-up ads, prevent you from scrolling, prevent you from right-clicking or zooming.
- We have more security vulnerabilities.
- Web browsers have to be constantly updated else everything stops working. Websites too.
- People waste lives on designing a completely useless language and solving problems they themselves arbitrarily create. Students waste time learning it and teachers waste time teaching it.
- Suicides are more common.
- ...

But this is just a small price for all the advantages JavaScript brought us, namely:

- nothing

And so we get to the number 1 rule of a good webdesign: NEVER use JavaScript. Website is not a program, website is a document, so it doesn't need any scripts. Privacy freaks hate web JavaScript because it's a huge security vulnerability (websites with JavaScript can spy easily on you -- yes, even if the script is "free software" and yes, even if it runs under VM and so on) -- we don't fancy security but JavaScript is still bloat and capitalist shit, it makes a website literally unusable in good browsers (those that don't implement JavaScript) so we hate it too. Basically everyone hates it.

In the past JavaScript was only a client side scripting language, i.e. it was used in web browsers (the clients) to make computations on the client computer (which suffices for many things but not all) -- as a browser language JavaScript interoperates with HTML and CSS, other two languages used on websites (which are however not programming languages). For server side computations PHP, a different language, was used, however later on (around 2010) a framework/environment called node.js appeared which allowed JavaScript to be used as a more general language and to be used for server side programming as well; as it's more comfortable to write everything in a single language, JavaScript started to replace PHP in many places, though PHP is still used to this day.

jQuery is a very popular library that's often used with JavaScript. It's kind of a universal library to do things one often wants to do. We mention it because everyone around JavaScript just supposes you'll be using it.

Why is it called JavaScript if it has nothing to do with Java? Simply put the name was chosen because back then Java was the big thing and they wanted to show that JavaScript is kind of similar but complementary, the developers of the languages were associated with each other and they thought it would be good marketing to associate the languages through naming, but of course the languages are completely different.

{ Kek in 2024 JavaScript killed the Internet Archive :D Some JS library allowed some kinda cracker to bring it down or something, as of writing this the archive has been dead for more than a week and a recovery is still nowhere in sight, of course this also crippled or killed many other sites that rely on JS such as Librivox. Good job soydev retards, I wonder whose idea it was to use JavaScript on the site. ~drummyfish }

TODO: some more shit

JavaScript is the most retarded language ever, right after Rust.

## Examples

Below is our standardized divisor tree program written in browser JavaScript:

    <html> <head> <script>

    // recursive function, returns divisor tree of x as a string
    function divisorTreeStr(x)
    {
      let a = -1, b = -1;

      for (let i = 2; i <= x / 2; i++) // find closest divisors
        if (x % i == 0)
        {
          a = i;
          b = x / i;

          if (b <= a)
            break;
        }

      return "(" + (a > 1 ? divisorTreeStr(a) + " " + x + " " +
        divisorTreeStr(b) : x) + ")";
    }

    function main()
    {
      while (true) // main loop, read numbers from the user
      {
        let x = parseInt(prompt("enter a number:"));

        if (isNaN(x) || x < 0 || x >= 1000)
          break;

        console.log(divisorTreeStr(x));
      }
    }

    </script> </head> <body onload="main()"> </body> </html>

## JavaScript Fun

Here let be recorded funny code in this glorious language.

This kills the JavaScript:

{ Found here: https://codegolf.stackexchange.com/questions/61115/make-your-language-unusable. ~drummyfish }

    clear(this);

That's right, the above code just makes JavaScript commit suicide by deleting its whole global thing. Well, actually it only works in some specific JavaScript shells. Browser JavaScript seems to be harder to kill as you can't delete the global uber objects such as document and window, but you can try something like:

    for (var v in window) if (v != "location") window[v] = 0; throw "";

That should nuke basically all functions and objects and then halt by throwing an exception, which could possibly be saved only by catching the exception and then manually reinstating everything. However if the goal would be only to disable any JavaScript code with a text snippet, the easiest would be putting in a syntax error, such as `}}}`.

Here is how to make your page work only with JavaScript turned off:

    <html>
    <head>
    <script>
    function nuke() { document.body.innerHTML = "<p>disable JavaScript to view this page</p>"; }
    </script>
    </head>

    <body onload="nuke()">
      <h1> My awesome page </h1>
      <p> My awesome page text :) </p>
    </body>

    </html>

{ NOTE: Remember that normally breaking compatibility on purpose is probably bad, it shouldn't be done seriously (don't waste effort on breaking something, rather make something nice, also censorship is always bad), but it's a nice troll :D Don't forget to have fun sometimes. ~drummyfish }

Or this will give an epileptic seizure to everyone who has Javascript on:

    <html>
    <head>
    <script>
    alert("Turn off Javascript to make it stop.");

    var count = 0;

    function go()
    {
      count += 1;
      document.body.style.backgroundColor = (count % 2) ? "red" : "blue";
      document.body.style.color = (count % 2) ? "green" : "yellow";
      document.body.style["font-size"] = (count % 64).toString() + "px";
      setTimeout(go,10);
    }
    </script>
    </head>

    <body onload="go()">
      <h1> My awesome page </h1>
      <p> My awesome page text :) </p>
    </body>

    </html>

Did you ever dream of visiting Las Vegas? There's no need, just insert this script to any page and watch:

    <script>
      setInterval(
        function()
        {
          for (var i = 0; i < 10; ++i)
          {
            var r = function(x) { return Math.floor(Math.random() * x); }
            var e = document.getElementsByTagName("*");
            e[r(e.length)].style =
              "background-color: #" + r(0x1000).toString(16).padStart(3,"0") +
              "; color: #" + r(0x1000).toString(16).padStart(3,"0") +
              "; margin: " + r(10) + "px;"   ;
          }
        },5);
    </script>

TODO: some JS nonsense like below (https://wtfjs.com/)

    "11" + 1  // "111"
    "11" - 1  // 10

## See Also

- shit
- Python
- Flash

Powered by nothing. All content available under CC0 1.0 (public domain). Send comments and corrections to drummyfish at disroot dot org.