Functions and Evolution
- Old-school JS and modern JS
- History and evolution
- Functions three ways
Difference between ES5 and ES6 - GeeksforGeeks
Functions - MDN Web Docs
Functions - learn-js.org
ES6 arrow functions
Arrow functions for beginners - Brandon Morelli
Introduction to TypeScript - GeeksforGeeks
More on Functions - TypeScript
In 1996, it was developed into a standard scripting langage by ECMA’s (then the European Computer Manufacturers Association) Technical Committe (TC39) and released as ECMAScript 1 (ES1) in 1997.
TypeScript was developed and released by MicroSoft in 2012 to deal with some of the deficits of JS as a programming language.
It is technically a superset of ES6 (which is a superset of ES5).
The current release of TypeScript (TS4.5) incorporates ES2022 modules and is supported by Node.js 16.x.x.
It turns out that the seemingly arbitrary and undisciplined way I use semicolons is… fine I guess?
I have always just used them intuitively based on what I thought was happening and I realize now that my usage was a vestige of writing bash scripts, where they have somewhat more explicit use as a command terminator. So when I would write one-liners, this was the mechanism that I used to put the lines together into one.
Apparently some people get mad about semicolons in JS.
So, my advice is to use them if you feel like it and if you ever encounter someone who gets super upset about them, then avoid that person.
Regular functions bind their own scope whereas arrow functions inherit from the parent scope.
What does this mean?
It means that arrow functions are limited in terms of what they can and can’t do:
- No binding to
- Can’t use as methods or constructors
- No good for
- No good for anything that rely on a scope
But they can be used with closures and are nice for when we are creating API endpoints, which we will do next week.
Modules and export
Modules, export, and import
The module object - Node.js
Node.js export module - GeeksforGeeks
ESM and CommonJS issues
You’re going to run into issues related to using the module, export, import.
Basically, you can’t use
require('blahblah') with ESM modules and you can't use import` with CJS modules.
BUT THAT IS OKAY!
Because there is a way to make it happen.
module.createRequire() - Node.js
Parsing command line arguments
How to parse command line arguments - Node.js
Command Line Arguments in Node.js - Scott Robinson
How to Parse Command Line Arguments in Node.js - Rahul Kumar