Search notes:

JavaScript

JavaScript = ECMAScript + DOM + BOM

Built-in types / objects

Primitive built-in types

The values of the primitive built-in types is data that is not stored with or in an objects.
ECMAScript defines the following primitive built-in types:
Type Range of values
Undefined one value: undefined
Null one value: null
Boolean true and false
Number IEEE-754-2008 64-bit double-precision numbers
BigInt (?, not defined by ECMAScript ?)
String A sequence of zero through 2⁵⁶-1 16-bit unsigned integer values («elements»)
Symbol The set of strings that may be used as the key of an object property
All primitive built-in types except null and undefined have object wrappers so that their values can be stored in or with objects.
The respective wrapper objects' valueOf() method returns the primitive value again.
TODO: compare with built-in objects.

Object

Then there is the non-primitive built-in type Object.

TODO

call vs apply

Destructing assignments

function x() { return {num: 42, txt: "hello world"}; }

const {num, txt, def='unassigned'} = x();
console.log(num);
console.log(txt);
console.log(def);

const {num: ft, txt: hw} = x()
console.log(ft);
console.log(hw);
function y({a, b}) { console.log(a * b);
y( {a: 7, b: 6} );

Modules

A module is a JavaScript unit that exports objects (such as functions or variables) (export keyword).
See also <script type="module">…</script>.
Modules are fetched using CORS.

ES Modules vs CommonJS

The ECMS standard (ES) is the official standard to package JavaScript for reuse. The corresponding keywords are export and import.
CommonJS is the original way to package JavsScript for Node.js. The corresponding keywords are module.exports and require().
Node version 13.2.0 has ES modules (as well?).
In order for Node.js to treat a module as ES module, there are three possibilities:
  • use .mjs file suffix
  • use the type field with a value of module in package.json
  • use the --input-type=module command line option
The suffix .cjs is used to mark a file as a CommonJS module.
ES Module:
import pkg from 'moduleName'
CommonJS:
module.exports.sym = …;
const pkg = require('moduleName')

See also

Javascript engines
jrunscript is a command line script shell whose default language is JavaScript.
Using the <script> element together with its language attribute to determine the version of JavaScript.
The latest drafts of the ECMAScript® Language Specification.
When writing code for the Web with JavaScript, there are a great many APIs available. Web APIs has a list of all(?) interfaces one might use to develop a program.
code snippets
Javascript helpers
Java Script objects
Object oriented JavaScript
Inline vs external Javascript
Java package javax.script
In Oracle 21c, dbms_mle allows to execute JavaScript «in» the database.
JScript and Microsoft's JScript compiler jsc.exe.
SpiderMonkey is a JavaScript-Engine which is written in C/C++. It is interesting because it has JavaScript shell.
Rhino is also an implemenation for JavaScript, it is written in Java, however.
Another shell is Node.js
JSON: JavaScript Object Notation
Dynamically change a CSS style with javascript
SVG/JavaScript examples
jQuery
Calling a simple JavaScript function from Visual Basic for Applications with the MS Script Control object.
The CSS @media at-rule scripting can be used to apply different stylesheets depending on if JavaScript is enabled.
Other programming languages
WebAssembly: A programming language that runs on browsers.
A browser's main thread.

Index