PPH l33t

Counting number of properties in a JS object

When there is a JS array, it is easy to count the number of elements. For example: var arr = [“hello”, “world”]; console.log(arr.length); // 2 However, when you have an object it is a bit more tricky. .length wont work. One way is to iterate…

Sprites and the :before element

Lets suppose you have a big sprite with icons place not only vertically, but also horizontaly, effectively creating a complex grid. Now lets suppose you want to create an <a> tag with an icon on the left side, and some text after that. If you…