Xah Talk Show 2019-09-13 Chinese input methods, understand JavaScript object in depth, in a math style

- https://youtu.be/8STFNgAv1wQ
- Chinese input methods, understand JavaScript object in depth, in a math style. Xah Talk Show 2019-09-13
topics covered:
- Emacs Chinese Input
- Chinese Input Methods
- Pinyin 拼音, Zhuyin 注音, IPA Comparison
- JavaScript in Depth
- JS: Value Types
- JS: “typeof” Operator
- JS: Property Overview
- JS: List Properties
First of all, understand JavaScript value types.
console.log ( undefined ); console.log ( typeof undefined === "undefined" );
console.log ( true ); console.log ( typeof true === "boolean" );
console.log ( typeof NaN === "number"); console.log ( typeof Infinity === "number" ); console.log ( typeof 3 === "number" ); console.log ( typeof 3.12345 === "number" );
- Object value type, the most important type of JavaScript
finding the type of a value
function ff (x) { return x+1 } console.log ( typeof ff === "function" );
what is object in JavaScript?
JavaScript object is:
- a collection of key/value pairs.
- each object may point to another object, called its parent object. (also known as its prototype object)
- a object, may have special purpose or associated with it some special data. For example, function is a object, but it can also be called like a function.
function ff () { return 3 }; console.log ( ff() ); ff.aa = 4; ff.bb = 5; console.log ( ff );
const aa = [3,4,5]; console.log ( typeof aa ); console.log ( Array.isArray(aa) ); console.log ( Reflect.ownKeys ( aa ) ); // this is what array is like as a property // {"0":3, "1":4, "2":5 , "length":someInternalMagicFunction}
const obj = {k1 : 1, k2 : 2}; console.log ( obj ); console.log ( Reflect.ownKeys (obj) );
// this is about inheritance. when js looks up a property's value, it tries to go up the parent chain const x1 = {k3 : 3}; const x2 = {k1 : 1, k2 : 2}; Reflect.setPrototypeOf ( x2, x1 ); console.log ( x2.k3 );
// this is about inheritance. when js looks up a property's value, it tries to go up the parent chain const x1 = {k3 : 3}; const x2 = {k1 : 1, k2 : 2}; Reflect.setPrototypeOf ( x2, x1 ); console.log ( x2.k3 ); x1.k3 = 4; console.log ( x2.k3 ); x2.k3 = 5; console.log ( x2.k3 ); console.log ( Reflect.ownKeys ( x2 ) );
