Xah Web Dev Blog

new pages.

new pages.

JavaScript: Iterable (ES2015) (new)

JavaScript: Interface (ES2015) (new)

A Brief History of JavaScript By Sebastián Peyrott. @ https://auth0.com/blog/a-brief-history-of-javascript/

JavaScript creator on JavaScript history. 〔Popularity By Brendan Eich. @ https://brendaneich.com/2008/04/popularity/

one of the most annoying thing about css is that there's no way to control size of font across browsers, unless you download web font.

JavaScript: Date Object and Properties

JavaScript: Date.prototype and Properties

the JavaScript date object reference page is now completely rewritten. Updated for ES6.

JavaScript: Date Tutorial

JavaScript: Date() Constructor (new page)

JavaScript Date.parse() (new page)

#JavaScript new Date.prototype properties in es6


JavaScript: Access/List Properties (updated for ES2015)

JavaScript: Creating Object with Object.create() (new page)

JavaScript: Object Literal Expression Extensions (ES2015) (new page)

JavaScript: Object Literal Expression {…} (new page)

JavaScript: Function Constructor (new page)

#JavaScript quirk of the day. Function.prototype is a function by spec. takes any number of args, returns undefined. others, e.g. Object.prototype, Array.prototype, are not functions.

JavaScript: Function.prototype Properties (new)

JavaScript quiz. what does this return Function.prototype()

million dollar JavaScript quiz. what does this return Function.prototype()

vote at

JavaScript: Object Object and Properties (new)

JavaScript: Reflect Object and Properties (ES2015)

JavaScript: Getter/Setter Properties (major update)

console.log() not in any standard

the critical function console.log() in browser console doesn't seem to be defined by any standard, but whatwg is taking steps. see


JavaScript: Array Object and Properties new.

how to build a local copy of whatwg html spec

finally got a local copy of whatwg html spec working. thx to Anne van Kesteren https://twitter.com/annevk and Ben Schwarz https://twitter.com/benschwarz

here's what you have to do.

  1. clone the git repo at https://github.com/whatwg/html
  2. clone the git repo at https://github.com/whatwg/html-build
  3. follow the instructions at https://github.com/whatwg/html/blob/master/CONTRIBUTING.md . You'll need curl, grep, perl, unzip. You do not need to install the “Whattsi” tool. (the “Whattsi” tool is written in pascal, and requires pascal compiler.)
  4. go to the “html-build” directory, run ./build.sh
  5. It'll ask you for full path of html source to build from. The full path is the git you cloned from https://github.com/whatwg/html. e.g. on my machine it's /home/xah/git/html/
  6. After done, the output is in directory output

After this, technically you are done. You have this directory structure:

build html spec local copy 2016 11 24

The embedded image in the html files are not relative paths. They use a server root path, like this:

<image xlink:href=/images/abstract.jpeg width=326 x=72 y=85 height=177></image>

and other assets:

src: url('/fonts/Essays1743-Italic.ttf');
<script src=link-fixup.js defer=""></script>

So, these asset won't work in your local copy. You need to fix it.

You need to use a good find/replace tool to replace them with ../ prefix, particularly for files in the multipage directory.

(for emacs users, you can use Emacs: xah-find.el, Find Replace in Pure Elisp )

after that, you are done.

however, note that the asset file links still refer to other full URLs, for example:

<script defer="" src=https://resources.whatwg.org/dfn.js>
<link rel=stylesheet href=https://resources.whatwg.org/standard.css>

You'll have to do a search on “http”, and for those CSS or JS etc files, you might download and replace with a local copy.

building whatwg html spec requires pascal compiler!

now in order to build whatwg html spec, you need to install pascal compiler. https://github.com/whatwg/wattsi EXASPERATION. i can never understand

ES2015 removed internal slot [[Class]]

js es5 has internal slot [[Class]]. That's removed in es6. But Object.prototype.toString() behavior is kept. see JavaScript: Determine Type of Object

web development pain, local copy of multi-page html spec

  1. tried to update my local copy of html standard spec. after 2 hours, no luck.
  2. i vaguely recall last year whatwg has download/build-from-git of the multi-page spec https://html.spec.whatwg.org/multipage/ but can't find it now
  3. on whatwg's git https://github.com/whatwg/html , no mention of how to build multi-page at all.
  4. then there's a edition for web devs. great. https://developers.whatwg.org/sections.html#sections but
  5. but web dev's version git https://github.com/benschwarz/developers.whatwg.org build process is idiotic. requiring ruby python mercurial! and gem rake whatnot.
  6. i build it, but partly failed wich mercurial and rake issues. the result html does not have CSS.
  7. digging, possibly even seccussful build does not have CSS, after all.
  8. a web page sans css is basically unreadable today.
  9. digging further, it's not clear the git for web dev version is up to date or still maintained. can't find date info or status.
  10. but that web dev edition is apparently still linked at top of https://whatwg.org/ site. so seems legit, but you never know, cuz open source stuff fail silently.
  11. note that w3c has their own html standard. also web dev edition. they too r complex to find, different sites, wiki, git, w3c etc.
  12. all this poor sob want is a local version of multi-page html spec. with haskell, git, hub, google AI in year of our load 2016, no.
  13. in then end, just use a browser, goto a url, press Ctrl+s to save. that'll be your local version, bad link and all. lol.

whatwg javascript spec doc gone

there used to be a doc 〔 https://javascript.spec.whatwg.org/ 〕 which is whawg's take on js spec problems. available as of 2015-08-24. But now it redirects to https://github.com/tc39/ecma262/labels/web%20reality which is a unreadable github issues on tc39/ecma262.

hates that. It should at least put a note from the original page telling readers that the doc is obsolete. even better is to have the note on top and content still remain for history purposes.

JavaScript: Object.prototype Properties (new page)

starting to rework my js reference section. instead of just list of methods, it should list all standard objects and their properties.

JavaScript: Object Object and Properties (new page)

JavaScript: Determine Type of Object (updated for ES6. More work to do.)

JavaScript es6 added Map and Set data structures. But remember, they are still the Object data type. The only added type is Symbol.

JavaScript: introduction to Symbol (ES2015) JavaScript: Symbol (ES2015)

JavaScript: Object Literal Expression Extensions (ES2015)

JavaScript: the Map Object Tutorial (ES2015)

my js es6 in depth is coming along nicely. JavaScript: the Set Object Tutorial (ES2015)

browser rendering of h1 in nested section

#html h1 tag inside nested <section> gets increasingly small, by browser css. but not h2, h3 etc.


nested section h1
nested section h1
<!doctype html>
    <meta charset="utf-8" />
    <style>section {border:solid thin blue; margin:1ex}</style>
    <title>test nested section h1</title>
      <h1>xyz 1</h1>
        <h1>xyz 2</h1>
          <h1>xyz 3</h1>
            <h1>xyz 4</h1>
              <h1>xyz 5</h1>
                <h1>xyz 6</h1>
                  <h1>xyz 7</h1>

death of multi-page web design

throughout the 2000s, there's multi-page style web sites. That is, a article is split into 2 or more web pages. You have to click next page to read other parts of the article. That practice is dead today few years ago. End of a era.

JavaScript es2015 is so great. No longer we have to do this abomination just to have local vars (function () { … })()

JavaScript: let and const Declarations (ES2015)

3 articles to read. probably all excellent.

An incomplete history of language facilities for concurrency By Andy Wingo. @ http://wingolog.org/archives/2016/10/12/an-incomplete-history-of-language-facilities-for-concurrency

A Study on Solving Callbacks with JavaScript Generators By James Long. @ http://jlongster.com/A-Study-on-Solving-Callbacks-with-JavaScript-Generators〕 This article too bleeding edge to be practical for consideration now. rather, just focus on understand es6 “promise” and generators.

Optimization killers By Nick S Plekhanov. @ https://github.com/petkaantonov/bluebird/wiki/Optimization-killers〕 The topic is too esoteric, and generally not needed. when you need to pay attention these things, it means the language have lots problems.

JavaScript: for-of Loop (ES2015)

JavaScript: Arrow Function (ES2015) (new page)

JavaScript: let and const Declarations (ES2015) (new page)

starting to work on es6 features.

CoffeeScript is no good, because it's a superficial surface syntax, bringing its own problems.

TypeScript is no the answer. It is a superset of js, so doesn't fix the real problem, that is, the bad parts of js.

DartLang isn't the answer. Because it is Java in semantics and syntax. Quite strange beast, and isn't a good lang by itself.

DartLang = dead horse breathing.

The main thing we need to fix is the many js's bad parts. JavaScript: the Bad Parts

JavaScript lib method definition style, in object curly bracket or outside object?

when you write a JavaScript lib, which style do you prefer:

vote at


js method def style poll google plus js method def style poll twitter
JavaScript method def style poll results.

JavaScript: Browser JS Console Object Syntax Error

Firefox is at 10% of browser market share

pretty sad. today, Firefox is at 10% of browser market share. Muscle man Chrome is 50%. Mozilla could be gone in a flash.

but Firefox quality has gone pretty bad for 5+ years now, for just basic browsing. Slow as hell.

for my website xahlee.info , mostly read by programers, chrome is 62%. Firefox 14%. Safari is 13%. IE 4%, Edge 1%

Meaning of Font Size and Em Height

The State Of JavaScript, 2016

The State Of JavaScript By Sacha Greif. @ http://stateofjs.com/2016/introduction/

A survey, of js compilers, langs, frameworks, etc.

there's a new js framework, vue.js. New js framework just keeps popping up. Amazing.

JavaScript quiz: will this work x[f](a)[g](b)

don't just guess. try it.

var s = 0;

var x = {

    f : function (a) {
        s += a
        return x

    g : function (a) {
        s += a
        return x



var f = 'param_f';
var g = 'param_g';
var a = 'Hello,';
var b = 'World!';
var x = {
    param_f: function(param_a){
        return {
            param_g: function(param_b){
                console.log(param_a + ' ' + param_b);


HTML: Allowed Characters in id Attribute (updated)

in HTML5 the id attribute string can be any char except space. e.g. it can start by digit, or #, or ♥

HTML XML Entities (old page, new url)

Xah JavaScript tutorial, 2016-07 update

New version is out.

Buy Xah JavaScript Tutorial

Lots things has been updated. Several page have been re-written from scratch.

Most of the DOM scripting tutorial are re-written. And am working on more complete tutorial of DOM scripting.

Also working on ES6 features.

If you bought it already, you'll receive update.

if you don't have it it, give it a shot! Thanks.

The Sad State of Web Development

You see the Node.js philosophy is to take the worst fucking language ever designed and put it on the server.

The Sad State of Web Development By Drew Hamlett. @ https://medium.com/@wob/the-sad-state-of-web-development-1603a861d29f

history of CSS: The Languages Which Almost Became CSS

The Languages Which Almost Became CSS By Zack Bloom. @ https://eager.io/blog/the-languages-which-almost-were-css/

User Interface design: navigation panel, with scrollbar or no?

which you prefer?

side panel UI static-s side panel UI scrollbar-s
Fisrst picture: static panel, scroll with page. Second picture: with its own scrollbar.

vote on twitter at https://twitter.com/xah_lee/status/747375376616165376

or vote on Google Plus at https://plus.google.com/+XahLee/posts/MebjN6pPy5T


JavaScript Execution Order (rewrote. improved clarity)

JavaScript: Intro to Event-Based Programing (rewrote)

Reddit greed level up'd.

reddit screen block 2016-06-22
now, reading reddit without login will popup prompt and block view.
JavaScript quiz variable in array 2015-08-09
JavaScript Quiz: Variable in Array

(repost. on its own page)

html frameset 2016-06-21
HTML: Split Windows; Frameset

HTML Frameset is actually really a good UI. Unfortunately, it's killed by geeks for geek reasons.

Today, there's still not a workaround.

see it here: HTML: Split Windows; Frameset

the Java doc is still in html frameset, and it won't be going away anytime soon. Java Platform SE 8

(wow, so this means, browser will actually not deprecate it!)

JavaScript: Semicolon Rules (major rewrite, again. Now, explaining the new school of omitting semicolon)

actually, i now tend to think omitting semicolon is better. The rule is just far more simpler. It is also great saver on typing. Also, the semicolon in js is really a pain, because when editing code, refactoring, change between statement and expression, you have to constantly add / remove semicolon. But if you omit them at all times now, you don't have this problem anymore.

Web Design: Relative Date Sucks

the fashionable web design date “posted 834 days ago” is fscking annoying.

it began several years ago… around 2008 maybe.

say no to it.

i think, it'll eventually change back, to real dates.

〔➤see Web Design

2 nice JavaScript lib for plotting math functions

function-plot. runs on top of d3js. features interval arithmetics. https://github.com/maurizzzio/function-plot/

jsxgraph. geometer sketchpad like lib. http://jsxgraph.uni-bayreuth.de/wp/index.htmlhttps://github.com/jsxgraph/jsxgraph

JavaScript: Semicolon Rules. Much update.

there are 2 schools of thought. One, the Douglas Crockford classicist, recommend adding semicolon. The other, often younger, JavaScript coding hotshots in industry, recommend ommiting semicolon at all times.

JavaScript SVG set style problem

3 hours spent debugging this

svgElement.setAttribute("style", styleStr)


svgElement.style = styleStr;

The latter does not work on a 2011 old android tablet running 3 years old CyanogenMod running Google Chrome (too lazy to check version).

JavaScript Quiz. Array Splice Insert Without Nesting

// js quiz

// you have
function add () { return ["a","b"]; }
var tt = [1,2,3,4];

// you want
// [ 1, 'a', 'b', 2, 3, 4 ]

// modify tt, using splice. How?

for answer, see JavaScript: Array Splice Example

JavaScript: Array.prototype.reduce and reduceRight Example (new page. Basic example.)

JavaScript: Compute Date Range

Understand Atomic CSS in 1 Minute

JavaScript: Flatten Nested Array

see also JavaScript: Array How-To

JavaScript: Array.prototype.every Example

JavaScript: Test Equality of Objects

now, a function that compare 2 arbitrary objects, by deep dive.

JavaScript: Array Compare Equality (updated)

JavaScript: DOM Whitespace Nodes (added more example)

never, use delete to remove element in a array. Use Array.prototype.splice. It is the most general way to insert or remove slices at any position.

See JavaScript: Array Splice Example

JavaScript: Method Chaining and Function Composition

new version of JavaScript in Depth is out. Sent to previous buyers.

Buy Xah JavaScript Tutorial

if you bought it before, please leave a comment or review at Buy Xah JavaScript Tutorial. Hopefully positive. Thanks.

JavaScript: Replace All Children, createDocumentFragment

JavaScript: Randomize DOM List or Element Children

web bugs is now called web beacon.

that is, those 1 by 1 pixel image file used for tracking. (and many other techniques, now being standardized if not already)

Beacon spec https://www.w3.org/TR/beacon/

json syntax vs JavaScript syntax

json syntax isn't just what JavaScript accepts. For example:

see also JavaScript: JSON Object and Properties

〔➤see Python: Read/Write to JSON

HTTP Protocol Tutorial (new)

CSS Random Gradient with JavaScript, at CSS Linear Gradient Tutorial

CSS Radial Gradient Tutorial (minor update)

Xah Web Dev Blog Archive Index

Like what you read? Buy JavaScript in Depth
or, buy a new keyboard, see Keyboard Reviews.