JS

A modern web application can use

Node.js and Express.js on the server side

Angular or react on the client side

JSON for data communication.

it must be :

REST: Representational State Transfer which means:

  • Use HTTP methods explicitly. (To retrieve data,use GET. To create data, use POST. To update or change data,  use PUT. To delete data use DELETE.)
  • Be stateless.  (“don’t store state information on the server”. use Angular or react to create an entire client-side MVC (Model–view–controller) setup where you can save and manipulate the state of elements without hammering your server.
  • Expose directory structure-like URIs.

Instead of:

http://app.com/getfile.php?type=video&game=skyrim&pid=68

You want:

http://app.com/files/video/skyrim/68

  • Transfer XML (Extensible Markup Language), JSON (JavaScript Object Notation)

========================================================================================

https://en.wikipedia.org/wiki/Comparison_of_JavaScript_frameworks

*Server Side: Node.js operates on a single thread event loop, using non-blocking I/O calls, allowing it to support tens of thousands of concurrent connections without incurring the cost of thread context switching. Node.js is an open-source, cross-platform JavaScript run-time environment that executes JavaScript code outside of a browser. Node.js can be combined with a browser, a database that supports JSON data (such as Postgres, MongoDB, or CouchDB) and JSON for a unified JavaScript development stack. With the adaptation of what were essentially server-side development patterns such as MVC, MVP, MVVM, etc., Node.js allows the reuse of the same model and service interface between client-side and server-side.

*Client Side: React (also known as React.js or ReactJS) is a JavaScript library for building user interfaces. It is maintained by Facebook and a community of individual developers and companies. React can be used as a base in the development of single-page or mobile applications. Complex React applications usually require the use of additional libraries for state management, routing, and interaction with an API. React and Vue, are both JS libraries for the view layer of Model-View-Controller (MVC). designed to be used alongside other programming tools.

*Client Side: Angular (commonly referred to as “Angular 2+” or “Angular v2 and above“) is a TypeScript-based open-source front-end web application framework led by the Angular Team at Google and by a community of individuals and corporations. Angular is a complete rewrite from the same team that built AngularJS.

+jQuery is a JavaScript library that predates full-fledged JS frameworks.  jQuery is intended for instances of individual problem solving in a JavaScript project. In other words, jQuery doesn’t establish a scaffolding for your project. jQuery plugins can be executed through a few lines of jQuery library code (versus the many lines of code it would take to perform the same function if you were coding it from scratch), and simplification of JS tasks like AJAX calls (using JS to call a server and update individual parts of a website without requiring users to reload an entire page). Not every project will be complicated enough to require the full framework treatment. Extensible frameworks like Vue allow themselves to be used alongside other tools like jQuery.

Ref: https://skillcrush.com/2018/07/30/best-javascript-frameworks-2018/

Ref: https://rubygarage.org/blog/best-javascript-frameworks-for-front-end

===========================================================

If you just have java script in a file it is better to save it as html:

// This file is Amirjs.htm I remarked next tags to prevent problems for wordpress
//<script type=”text/javascript”>

myFunction(); // Call the function

function myFunction() { // Declare a function
alert( “Hello World!”);
}

//</script>

 

http://www.yaldex.com/FSButtons.htm

==================================

“TypeScript is JavaScript for application-scale development”. It is managed by Microsoft. By defining types in your code, you allow the IDE to acknowledge errors in the use of classes and functions that would only be perceived at runtime. You can write your code in Typescript then compile it. The compiler generates a javascript file (.js) and a map file (.js.map).

Node.js is an engine that runs Javascript and not Typescript. The node Typescript package allows you to transpile your .ts files to .js scripts.

Typescript code:

const amirVar: string = Hello”;

compile JavaScript code:

var amirVar = “Hello”;

https://www.tutorialspoint.com/typescript/typescript_overview.htm

https://www.typescriptlang.org/docs/handbook/typescript-in-5-minutes.html

===============================

JS Execution contexts

 

======================================