How to write a singleton class in javascript

If I look at my stats, a lot of people are wondering how to write a singleton class. I already wrote about it before but my old solution exposed the instance of the class so more than one instance could be created thus making it not completly a singleton class.

Read the complete article...

How to create an object with private variables and methods

In short, you can use private variables when you return another scope when declaring a class.

Read the complete article...

How to use JSON (updated with example)

This post is an update from the old post. A lot of things changed since it was written and the information in the old one is a bit outdated.

Read the complete article...

Easy loop for every element of an array

There’s something bugging me with javascript for loop : the extra work to loop though all elements of an array. Suppose I want to alert each element of an array, there are three ways of doing it.

Read the complete article...

Be ahead of the trend, try CouchDB

I always loved and hated databases. When I was a younger programmer, I asked to switch to DB administrator and, thank God, they didn’t agree to let me mutate in a DBA. I ended up fired like 80% of the company (except the DBA). In fact, I wanted to be DBA because I thought I [...]

Read the complete article...

Cleanest way of executing javascript code on page load

Everytime that I work on a new project, I’m always unsure about which way to execute javascript on page load.

Read the complete article...

JavascriptKata now ad free

[Update 2009-09-20 : I will try to bring back ads. I removed them because I was frustrated, I bring them back as an experience.]
JavascriptKata was created in the blog bubble. In a time when all you had to do was to create a blog, put ads on it and you were rich. It never was [...]

Read the complete article...

Load a page with javascript

Someone asked me : “I would like this site to automatically load a certain page (1-31) depending on what day of the month it is (1-31)”

Read the complete article...

Javascript for PHP lovers

I’m not a PHP guy and I like to use standards for the languages I’m using so this php.js thing is not for me at all. In fact, I really dislike PHP and though I use it often, there is no reason in the world I would want to use its syntax to write javascript.
Import [...]

Read the complete article...

How to have jQuery and prototype.js in the same project

I’m a big fan of jQuery. This librarie is just the best and simplest one around. I really noticed it when I wanted to get rid of jQuery in TimmyOnTime and try to use prototype.js instead, just to be more “rails-oriented” (that’s a pretty lame excuse don’t you think?)
Why I didn’t like prototype.js
There was not [...]

Read the complete article...