The classic command for running a simple web server from a shell is:
python -m SimpleHTTPServer [«port»]
As a result, files are served at http://localhost:«port»
, with 8000 being the default if you omit the port.
When statically generating HTML content, you face an interesting challenge: If the page frame (the “chrome” of a page) contains information that changes frequently, you need to re-generate all pages every time it does. One example of such information is a top 10 list of the pages that were most popular during the last 30 days.
This blog post explains how to use the Analytics Core Reporting API by Google from Node.js.
Let’s use that API to create a Node.js script analytics.js
that downloads the top 10 most visited pages of your website.
This blog post explains how to use ES6 Proxies to intercept method calls to an object.
Read chapter “Meta programming with proxies” in “Exploring ES6” for more information on Proxies.
Enumerability is an attribute of object properties. This blog post explains how it works in ECMAScript 6.
Let’s first explore what attributes are.
Typed Arrays don’t have a method concat()
, like Arrays do. The work-around is to use the method
typedArray.set(arrayOrTypedArray, offset=0)
There is a subtle difference between an object with methods and an object with callbacks.
In ECMAScript 6, the object Symbol
has several properties that contain so-called well-known symbols (Symbol.iterator
, Symbol.hasInstance
, etc.). These let you customize how ES6 treats objects. This blog post explains the details.
__proto__
in ECMAScript 6The property __proto__
(pronounced “dunder proto”) has existed for a while in most JavaScript engines. This blog post explains how it worked prior to ECMAScript 6 and what changes with ECMAScript 6.