July 2006
4 posts
2 tags
PHP-style Serialization of JavaScript Objects
Heavily-scripted data entry forms that expand on-the-fly as the user enters new data make life easier for the user. However, it can be hell for a developer to devise a method for the representation and submission of data with arbitrary length and depth.
A logical thing to do seems to be to take an object-oriented approach to represent all client-side data as one or multiple JavaScript objects....
1 tag
Don't Hand-count Characters
A common mistake that most programmers do is to hard-code hand-counted lengths of string literals. For example:
if (!strncmp(str, "MAGIC_PREFIX_", 13)) {
...
}
Even if the string literal "MAGIC_PREFIX_" is not due to change in a life time, it makes the code more prone to human error and harder to read when the length of the string is hand-counted and hard-coded as a separate entity (13 in...
Spelling "Quake" With The Quake Logo
I created this GIF animation back in 1997, when I used to play Quake 25 hours a day. I recall the tedious process of manual tweening to create the individual frames (by calculating the angle and position differences and dividing them by the number of frames) using Freehand. I would probably use Flash if I were to do it today…
1 tag
Finding Out Class Names of JavaScript Objects
JavaScript lacks a built-in function for getting the exact class names of object instances. The typeof operator just returns “object” for instances of both Object and Array, as well as user-defined classes. The following example illustrates this:
function MyClassA() {
}
var obj = new Object();
var arr = new Array();
var myobj = new MyClassA();
document.write(typeof(obj) +...