Xah Web Dev Blog Archive 2014-05

JavaScript: 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.

JavaScript: Operators (new page)

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

〔►see JavaScript: Functional Programing

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

JavaScript: String is 16-Bit Unit Sequence (on its own page)

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

CSS: Letter Spacing, Word Spacing

CSS: Font Weight, Bold

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

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