Code Notes

JavaScript

Tips and tricks I learned throughout the years.

JavaScript looks familiar to many engineers, but behaves differently in all the places that matter. Here I share practical lessons that help whether you're just getting started or already shipping in production.

JavaScript tips - Page 5

Not all arrays are arrays

You modified the Array object to include some of your custom methods. You create an array, you use the method and get an error: Array.prototype.loop = function (fn) { var length = this.length; for (var i=0;i

Read article

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 does is print a text …

Read article

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 religiously recommended that …

Read article

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 inconsistently offers solution to …

Read article

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 working tirelessly to keep…

Read article

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. Here is a little t…

Read article

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 cookies work is that t…

Read article

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 the animation as sm…

Read article

Previous Page 5 Next