Xah Web Dev Blog Archive 2013-11

CSS Selector Syntax (new syntax coloring)

much improved syntax coloring on the whole site. For example, see: JS: Array.prototype

JS: paren optional in x=new F() and x=new F. JS: Operator “new”

possibly i'll have a first phone interview with Google engineers. The human resource asks me about googlers i know. Who can give a helping hand? thanks. (xahlee@gmail.com)

Javascript, Design Patterns, Software Engineering, Appoach to Computer Language Tutorials

JS: Access Property, List Properties

JS: Check Property Existence

JS: Property Attributes

spent the past 3 months studying JavaScript in depth. The following are entry points.

JavaScript object system is very different from Java or Python. So it takes some used to, yet it's rather much simpler than Class/Object based system. However, the language itself is a bit convoluted.

I'll be keep updating these pages in coming weeks. I hope you like it. If you do, help spread it. Thanks.

The grand finally. JavaScript Objects Tutorial: Understanding JavaScript Objects

JS: Prevent Adding Property

JS: What's Object?

JavaScript function has a .length property. Its value is the number of parameters declared in the function. see JS: Function Parameters

JS: document.write

JS: What Does the Keyword 「new」 Do Exactly?

JS: “instanceof” Operator

JS: Determine Type of Object

Internet Explorer  anime girl 96030
〔►see Internet Explorer Anime Girl

JS: Using Map with Second Argument for Function's Object Context

Some array methods, such as myArray.map(f, o), takes a optional second argument o as the context object. That is, the object o becomes the value of this keyword in the function f. Here's a example:

// example of using map with a second object for function's context

var ff = function (x) {
    this[x.toString()] = x+1;   // add a property to the object this function is context of
    return x+1;
}

// new object
var oo = {};

// array
var a1 = [1,2,3];

// map ff to a1, with context oo
var a2 = a1.map(ff, oo);

// new array value
console.log(a2);                // [ 2, 3, 4 ]

// oo is changed
console.log(oo);                // { '1': 2, '2': 3, '3': 4 }

JS: Array.prototype (updated)

How Much Can You Make by Blogging? the Ease of Professional Blogging (updated)

JS: What's “this” Keyword?

JS: How to Determine Strict Mode?

Example of JavaScript Sort Method Using Custom Predicate

// array sort example
var aa = ["a1", "a70", "a8", "A2"];

// default sort. element compared as string
aa.sort();
console.log(aa);                // [ 'A2', 'a1', 'a70', 'a8' ]

// sort by comparing as numbers after first char
aa.sort(ff);
console.log(aa);                // [ 'a1', 'A2', 'a8', 'a70' ]

function ff (x,y) {

    var nx = parseInt(x.slice(1)); // remove first char. consider rest as number
    var ny = parseInt(y.slice(1));

    if ( nx < ny ) { return -1; }
    if ( nx > ny ) { return 1; }
    if ( nx == ny ) { return 0; }
}

JS: Array.prototype (updated)

Internet Explorer Anime Girl (oldie, on its own page)

HTML5 Audio Tag Tutorial (updated)

JavaScript Tutorial: Understanding Prototype and Inheritance

best Ruby book is David Flanagan's Ruby Programming Language and Best JavaScript book is his JavaScript Definitive Guide JavaScript Book by David Flanagan, and Man-made Complexity in Computer Language

JS: What Are Getter and Setter Properties and How to Create/Use Them

Like what you read? Buy JavaScript in Depth