Category JavaScript

JavaScript Simple and Elegant Function Chaining

A very simple Array prototype that chains functions listed in it via function outputs. This is not an object function chaining. It just connects or pipes function outputs to the next function in the array.  It is a short and simple snippet, that eliminates a lot of brackets and improves readability and encourages small (max […]

JavaScript deterministic object stringify

For some time I needed to use objects as a hash table (associative array) key in JavaScript, and for all that time I skillfully evaded to wrap my head around it. JavaScript objects (hash tables/associative arrays) are unordered data sets which means that the property (key) order isn’t guaranteed. I believed that for(var i in […]

JavaScript using objects as keys

If you ever wondered how associative arrays work or way are they called hashes in Ruby? The answer is hash tables, and if you look into the wikipedia article http://en.wikipedia.org/wiki/Hash_table, you can understand how they work and how simple they are. I will try to be quick and concise in the explanation: Introduction to Hash Tables […]

JavaScript Map class

Java like Map class for JavaScript, a wrapper arround JavaScript’s native key value hash tree storage inside objects. If you are familiar with Java Map this shouldn’t be news to you. The idea is this: enable the key value storage with some additional functionality, speed up iteration, and harvest the speed of native hash table […]

JavaScript object comparison

Function for deep comparison of object instances and arrays in JavaScript. It compares all data types except functions, because functions are not data, nor they should contain it. All functions should be unique, two same functions don’t make sense and/or use. This article covers the detailed explanation of an approach to solve the deep object […]

JavaScript require / import / include modules

Require, import or include, name it as you wish but never forget the importance of modular design. This functionality enables you to divide your code into meaningful, purposeful and reusable modules enabling you to use your code as many times as you want and easing it’s maintenance. This functionality is supported in almost all modern programming languages like: […]

JavaScript elegant namespace declaration

Emulating multilevel namespaces behavior in JavaScript shouldn’t be so complicated. We all know that namespacing in JavaScript is done by nesting objects. But for each nested object we have to check if it already exist so we wont overwrite it with the new object. This can happen if you write a lot of code and […]