Xah Web Dev Blog 2014-05

JS: Array How-To

JavaScript quiz: why doesn't this work?

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

var obj = { "a":3, "b":7, "c":2, "d":9};

var keys = Object.keys(obj);

var sorted_keys = keys.sort(function (a,b) {return obj[a] >= obj[b]});

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

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

JS: 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 JS: Array.prototype]

[see JS: Functional Programing (pre ES2015)]

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

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

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

CSS: Letter Spacing, Word Spacing

CSS: Font Weight

CSS: Text Decoration: Underline, Overline, Line-Through

What's a Letter in CSS's first-letter Pseudo-element?

CSS: Match first-letter and first-line

If you have a question, put $5 at patreon and message me.