JS started for the web and executed within web browsers. With the coming of Node.js in 2009, it became possible to use JS for server-side execution. It's now possible to build entire web apps with JS for both frontend and backend code. Today, the JS ecosystem is rich and mature with many libraries, frameworks, package managers, bundlers, transpilers, runtimes, engines and IDEs.
With the advent of NodeJS, JS was quickly adopted for server-side scripting. JS can be used for both frontend (client-side) and backend (server-side) programming of web apps. A developer therefore needs to learn only one language. This is particularly important when there's a demand for fullstack (frontend + backend) developers.
By mid-2000s, AJAX became a common approach to use JS more effectively for richer user experience. With AJAX, user interactivity is continued while new content is fetched asynchronously in the background.
Since we can now run JS on both client and server, this gives us the flexibility to render part of the web page on server and let the client complete the rest. This approach leads to what we call Isomorphic or Universal Application.
forloops, and module-level variables.
Some useful things to learn include effective console logging, destructuring, template literals, and spread syntax. Explicit loops can be avoided by taking the functional programming approach with
filtermethods. For asynchronous programming, you should learn about Promises and adopt the modern
Get a good understanding of closures and partial application. Use the arrow syntax of ES6 for more compact and readable code. Other useful ES6 features to learn are
const, multiline strings, default parameters, and module import/export.
What's the difference between a JS engine and a JS runtime?
Another important distinction is that the engine does synchronous processing. It can process only one function at a time via the call stack. On the other hand, the runtime can maintain a number of items in the callback queue. A new item can be added anytime to the queue and processed later when the call stack is free. Thus, the runtime enables asynchronous processing.
Consider the following:
- Frameworks: These simplify development by providing a structure, including design patterns such as MVC. Examples include React, Angular, Vue, Backbone and Ember.
- Libraries: Many developers release their code as JS packages/modules/libraries so that others can reuse them. In December 2018, about 836,000 libraries were available on NPM.
- Package Managers: Developers use them to install and manage packages they require for their projects. Examples include NPM and Yarn. Packages are downloaded from known repositories on the web.
- Linters: These catch errors or bad practices early. Examples include Prettier and ESLint.
- Module Bundlers: A project may have many dependent JS packages. Bundlers combine them into far fewer files so that these can be delivered more efficiently to browsers and other runtimes. Examples include Webpack and Browserify.
- Task Runners: These enable automated development workflows such as minifying or concatenating files. Examples include Gulp and Grunt.
"Hello world"of type "string" versus
Because there are many JS frameworks, libraries and tools, the choice of which one to adopt can be daunting. In one example, it was shown that Vue.js was hardcoded to rely on
yarnand this broke the workflow because the developer had only installed
npm. It's also possible in the JS world to have a small project of just few lines of code download lots of dependencies. An average web app has over 1000 modules.
At Netscape, the idea is to invent a dynamic scripting language for the browser that would have simple syntax and appeal to non-programmers. Brendan Eich is contracted by Netscape to develop "Scheme for the browser", Scheme being a language with simple syntax, dynamic and powerful. Thus is born Mocha, which becomes part of Netscape Communicator browser in May 1995.
- Ahmed, Kamran. 2019. "kamranahmedse/developer-roadmap." GitHub, January 26. Accessed 2019-02-03.
- Berners-Lee, Tim. 2019. "What were the first WWW browsers?" FAQ, W3.org. Accessed 2019-02-03.
- Chauhan, Shailendra. 2015. "Brief history of node.js and io.js." DotNetTricks, December 31. Accessed 2019-02-03.
- Garrett, Jesse James. 2005. "Ajax: A New Approach to Web Applications." Adaptive Path, February 18. Accessed 2019-02-03.
- Jackson, Brian. 2018. "100+ Awesome Web Development Tools and Resources." KeyCDN, August 02. Accessed 2019-02-03.
- Microsoft GitHub. 2019. "Microsoft/ChakraCore." February 01. Accessed 2019-02-03.
- Putano, Ben. 2017. "Most Popular and Influential Programming Languages of 2018." Stackify, December 18. Accessed 2019-02-03.
- Tjhung, Wilsen. 2018. "ES5 vs. ES6 Syntax." Autotrader & Carsguide Engineering, on Medium, November 08. Accessed 2019-02-03.
- Wikipedia. 2019b. "Mosaic (web browser)." Wikipedia, January 27. Accessed 2019-02-03.
- Wikipedia. 2019c. "Netscape." Wikipedia, February 02. Accessed 2019-02-03.
- Getify GitHub. 2018. "You Don't Know JS (book series)." November 18. Accessed 2019-02-03.