Message from JavaScript discussions

March 2017

— All too often js devs take advantage of the antipattern js allows, and that is another contributor to bad js in the wild imo

Message permanent page

— 

A great basic example, which is the one I see most commonly, is event listeners (or rather lack of them) in favor of element attributes like onchange or onclick

— This is incorrect and should never be used

<input type="text" name="date" onchange="validateDate()" />

Message permanent page

— I read parts of it at a library and decided it was a bit below my skill level, but I found it to be very well written

Message permanent page

— Javascript

A powerful, object-based, interpreted scripting language, created by Brendan Eich, most commonly embedded directly into HTML web pages to manage client-side interaction.

JavaScript is so beautiful and elegant it brings tears to my eyes. I love using it. It completes me as a person.

Message permanent page

— Urbandictionary javascript meaning

— The should part is quite subjective.

— Heavy use of FP constructs can make code hard to parse unless the actions are very clearly defined.

— Which is why you encapsulate those moving parts in OOP

— Take a basic FP concept, a projection. A projection is a string of functions combined to create a single result.
Here's the most basic way to do it:

var myResult = myFunction(myFunction2(myFunction3()));

And here's a way to do it which makes both more readable and less verbose:
var myResult = run(myFunction1, myFunction2, myFunction3);

Finally, here's another way to do it which involves OOP, and requires each function to return myObj, a concept jQuery users may be familiar with:
var myResult = myObj.myFunction().myFunction2().myFunction3().value();

All 3 examples do the same thing in terms of giving Function A's output to Function B's input and so on.

Message permanent page

— The last one, because it is a combination of FP and OOP, happens to be not only the easiest to write, but also the easiest to read.

Message permanent page

— (the .value() function at the end runs the projection)