Posts

Showing posts from September, 2015

Customizing ES6 via well-known symbols

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. Warning Implementation of the features described here is work in progress. Consult the “ ECMAScript 6 compatibility table ” for what is supported where (spoiler: not much, in few engines). Background This section covers knowledge that is useful for the remainder of this post. Additionally, the following material may be of interest: Chapter “ Symbols ” in “Exploring ES6” Chapter “ Values ” (primitive values versus objects, etc.) in “Speaking JavaScript” Internal properties The ES6 specification uses internal properties to describe how JavaScript works. These are only known to the spec and not accessible from JavaScript. They may or may not exist in an actual implementation of the language. The names of internal properties are written in double square brac...

The Theft of Memory

Image
Memory is not an exact, camera-like, permanent process.   “Neuroscience, which has undergone extraordinary breakthroughs over recent years, tells us there are reasons to distrust what we are certain we remember,” Jonathan Kozol writes towards the end of his new memoir, The Theft of Memory:  Losing my Father One Day at a Time (Crown, 2015).   Age and illness often have their way with us.   The worst is the scourge of Alzheimer’s disease which robs its victims of their memories and decimates their personalities while caregivers must bear witness to the destruction.   In spare, clear prose, Kozol takes us through the final years of caring for his parents, one of whom, his father, suffers from Alzheimer’s.   It is a heartbreaking, yet unfortunately not uncommon, story. Kozol is best known for his chronicles of poverty and educational deficiencies , especially for children of color, in American society.   His books Death at An Early Age (Plume, 1985), The...

__proto__ in ECMAScript 6

The 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. For this blog post, it helps if you know what prototype chains are. Consult Sect. “ Layer 2: The Prototype Relationship Between Objects ” in “Speaking JavaScript”, if necessary. __proto__ prior to ECMAScript 6 Prototypes Each object in JavaScript starts a chain of one or more objects, a so-called prototype chain . Each object points to its successor, its prototype via the internal property [[Prototype]] (which is null if there is no successor). That property is called internal , because it only exists in the language specification and cannot be directly accessed from JavaScript. In ECMAScript 5, the standard way of getting the prototype p of an object obj is: var p = Object.getPrototypeOf(obj); There is no standard way to change the prototype of an existing object, but you can ...

The Cognitive Rollercoaster

Image
Albert Ellis’ work with Rational Emotive Behavior Therapy (REBT) struck a chord with me as I was reading his work this week.   In his view, people disturb themselves by their own rigid and extreme beliefs about events in their lives.   I could relate to this in a way, because I often set unrealistic standards for myself or refuse to back down when facing a task that is clearly beyond my capability.   Since I’ve been recently diagnosed with a heart valve problem, it is crucial that I be careful with stress and anxiety to control my blood pressure.   Heat and other external factors can also cause complications if I am not careful.   My diabetes and kidney issues must be carefully monitored and kept under control so that I avoid any other problems.   I am often tempted to overdue my activities which leads to stress on my heart and low blood sugar.   It is hard to accept that I cannot do what I used to as a younger man. In a search for balance in my life...