Node.js Dot Notation as Namespace Mechanism

By Xah Lee. Date: . Last updated: .

In node.js, when you have a dot notation like

x.y

the x is used purely as a namespace, not as β€œdata”.

Example:

const p = require('path');
const x = p.extname('xyz.html')
console.log ( x ); // .html

This is true for about all node.js objects.

This is interesting because the item before the dot is usually considered as a object that represent a piece of data in Object Oriented Programing languages. For example, in JavaScript:

" x ".trim()

Unix Pipe, Dot Notation, Postfix Notation

  1. Dot Before Data or After?
  2. Node.js Dot Notation as Namespace
  3. Unix Pipe as Functional Language
  4. Method Chaining, Postfix Operator, and OOP
  5. JavaScript Dot Notation, Namespace or Object System?
  6. Ontology of Postfix Notation, Method Chaining, and Unix Pipe
  7. Piping and Function Composition Equivalence

If you have a question, put $5 at patreon and message me.