Wednesday, August 25, 2021

Some JavaScript Tips

Javascript requires discipline. You can easily create a giant mess. The language allows it. That doesn't mean you should. I've seen and worked on modular, object-oriented driver software written in assembly language. If a clean project and codebase can be done in assembly language, it can be done in javascript.


Use a lint

read other people's code, especially popular things like jquery, node, etc

Follow Crockford's advice about which features to use and which to avoid, e.g. always use === over ==. You almost never want what == does. Just don't use it at all. He has a lot of tips like that.


One good way to learn is to take somewhat complex functions/libraries and write them from scratch, and then compare your source code to the official source code. I did this with jQuery.Deferred, and it was really interesting to see how different my code was from the actual code.

No comments:

Post a Comment

Feel free to comment, ask questions if you have any doubt.