How to Create a 2D Array in JavaScript

JavaScript does not have a special syntax for creating multidimensional arrays. To create a 2D array in JavaScript, we have to create an array and then make each element of the array an array as well. That means we create an array of arrays. Example: The problem with this approach is that each element of… Read more

Published on March 26th, 2014 by Stephani

Making a div become a circle

To make a div become a circle use the following CSS code-snippet. On the HTML document: On the CSS document: Before applying the CSS above After applying the CSS above. Play with the code here

Published on December 9th, 2013 by Stephani

What Is The Difference Between Event Bubbling and Event Capture?

Let’s start with an example: If you click on the inner-div, it will cause a click event on both divs (inner-div and outer-div), but which event fires first? Event Capture: The event handler of outer-div fires first, then event handler of inner-div fires last. Event Bubbling: The event handler of the inner-div fires first, the… Read more

Published on September 26th, 2013 by Stephani

Creating a Queue in Javascript

To create a queue in javascript simply use an array. Arrays in javascript already contain both queue and dequeue methods necessary to manipulate a queue. They are just not called queue and dequeue. To enqueue into a queue, simply use the method push. To dequeue from a queue, simply use the method shift. The method… Read more

Published on September 25th, 2013 by Stephani

Creating a Stack in Javascript

To create a stack in Javascript simply use an array. Arrays in javascript already contain both push and pop methods necessary to manipulate a stack. The method pop() removes the last element in the array. This creates a LIFO (Last in, first out) effect. If you want to create a stack object with more methods,… Read more

Published on September 25th, 2013 by Stephani
load more...