Xah JS Blog. 2014-05 to 2014-05

Array How-To

JavaScript quiz: why doesn't this work?

// JavaScript quiz. Why doesn't this work?

const jj = { "a": 3, "b": 7, "c": 2, "d": 9 };

const xkeys = Object.keys(jj);

const ykeys = xkeys.sort((a, b) => jj.a >= jj.b);

console.log(ykeys);
// [ 'c', 'a', 'b', 'd' ] ??

ANSWER (rot13): [orpnhfr gur fbeg zrgubq'f cerqvpngr shapgvba arrqf gb erghea artngvir mreb cbfvgvir, abg gehr snyfr.]

Operators (new page)

JS: sum array

// example of writing a sum function
function sum (list) { return list.reduce(function (a,b) {return a+b;} );}

console.log(sum([3,1,2]));          // 6

[see Array.prototype]

[see JS: Functional Programing (old. before 2015)]

now complete. Computer Languages Characters Frequency (with JavaScript + svg charts)

Character, Code Unit, Codepoint (on its own page)

JavaScript DOM “setAttribute” — the pain in functional programing's neck.

CSS: letter spacing

CSS: font-weight, bold

CSS: Text Decoration, underline, overline, line through, wavy

CSS: What is letter in first-letter pseudo-element (2009)