Since ajax, a lot of people are thinking that asynchrone means “in a separated thread”. They are wrong! Synchronous The XMLHttpRequest object gives you the option to make a synchronous request to a server with the parameter async set to false. It means that when you call the server, all javascript executions will stop and [...]
I really don’t like the “non-destructive” expression but I couldn’t come up with a better one. What? You want to create a function but you will overwrite the old one. You just want to add some code before or after it. Example, you create a javascript applet that can be added to web sites you [...]
Posted on April 24, 2007, 8:10 am, by Dan, under
black belt.
I talked earlier about bookmarklets and how wonderful they are. In today’s web2.0 world, you can’t have a successful application without giving your users a cool bookmarklet. It can be easy to do sometimes (like the one of del.icio.us) but you always want to do more and it gets more complex… until the day you [...]
Posted on April 19, 2007, 10:15 am, by Dan, under
black belt.
The day I discovered it, I was really happy. Not happy as a fish in water but maybe happy as a cat having its meal (though it enormously depends of which cat we are talking about). Talking about bookmarklet to some of my friends, I saw that there were a lot of incomprehension about it. [...]
Posted on April 11, 2007, 5:17 pm, by Dan, under
black belt.
I recently wrote about closures and how easier your javascript will be to maintain and how good it will look. Now is the time for me to be a Closure-Grinch. Closures keep a reference to a variable, not a copy [source:javascript] // Create a Buy Viagra function function buyViagra() { var pills = 2; // [...]
Now is the time. I can’t go forward if I don’t talk about closures. What are closures? Closures are your friend. That’s the first thing you need to know about them. They will help you keep your code clean, healthy and easy. A closures is created every time you create a function in a function [...]
Posted on April 5, 2007, 5:51 pm, by Dan, under
black belt.
When I decided to start Javascript Kata, a friend of mine just thought it was a cool idea and started his own site, Ruby Fleebie. I’ve never written code in Ruby but it looks like a very pleasant language. He borrowed me Agile Web Development with Rails: A Pragmatic Guide and I really liked the [...]
[UPDATE : This post is outdated. Check out the new post on singletons.] Singleton is one of the most common and easiest design pattern. In fact, a lot of designs are wrong just because the developer didn’t know about singletons and design patterns (I could have said : a lot of my designs were wrong [...]
As I said earlier, objects are hash tables of properties and functions so looping throught them is done the same way (weepee!). The “in” statement The in statement must be used in a for loop. Like this : for (var element in allElements). In most of the other languages, the element variable would contain the [...]
Posted on March 29, 2007, 12:10 pm, by Dan, under
black belt.
Javascript has no hash table object but you can emulate one by creating a simple object and using brackets. [source:javascript] var hashPetName = new Object(); hashPetName["dog"] = “Rex”; hashPetName["cat"] = “Mistigri”; alert(“My dog’s name is ” + hashPetName["dog"] + ” and my cat’s name is ” + hashPetName["cat"] ); [/source] Great! That’s it about javascript [...]