JavaScript

Tips and tricks I learned throughout the years.

JavaScript is different. Experienced users that come from other languages have a hard time learning it, because it looks similar but operates differently. Here I will share all the insights I learned in the past few years. You will find it quite useful whether you programmed for years, or are just getting started.

JavaScript tips — Page 5

The whole page just went blank

There is an issue that beginners JavaScript developers frequently face. You read a few tutorials and learn about document.write(). It is equivalent to echo in PHP, or print in many languages. All it d…

Read

Asynchrounous JavaScript

If you learn a JavaScript tutorial today, chances are they told you that all the scripts are loaded in the head of the document. Then as you advance in your learning, you will see that it is religious…

Read

When to run your code

When is the right time to run your JavaScript? When the page has loaded? When the document is ready? You may face this challenge and the solution sometimes is not so simple. The Browse inconsistentl…

Read

IE hack

There was a little hack that I used to detect internet explore using JavaScript. I don't know if I should say "Too bad" it doesn't work as well anymore. Lately the Internet Explorer team has be workin…

Read

Command line tabular format

If you want to display tablular data on the browser, all you have to do is use a table. If you happen to want to display it in the terminal window (or in a pre tag), it becomes a little more difficult…

Read

Use local storage and fall back to cookies

Cookies There are better ways to save information on the browser then using cookies. Cookies save all values in one long string and has to be parsed every time you need to retrieve a value. The way c…

Read

Use of requestAnimationFrame for animation

It's hard to see what requestAnimaionFrame() does without reading about it. The traditional way of doing animation is to generate one frame then then run setTimeout at a specific time interval to make…

Read

Parse JSON string, cross browser

JSON stands for JavaScript Object Notation. You would think it would be second nature to parse those strings from your Ajax request, but not so much for older browsers. The modern browsers do have the…

Read

Photography