bilby.js & lenses

In JavaScript nearly everything is mutable. This can cause problems in your code when you think you have a new object or variable but instead you are operating on the referenced object. So, we create patterns to alleviate this problem. Or we use libraries like underscore.js or lodash.js which incorporate the functional concepts. Unfortunately they don’t always use immutable objects either. Bilby.js solves the mutability problem by using lenses. Using the lenses pattern one can access and change one’s objects in a safe and immutable manner. [Read More]

Functional Immutability in JavaScript

This is taken from Michael Fogus’ book Functional JavaScript in the chapter Purity, Immutability, and Policies for Change. Immutability is impossible to achieve in JavaScript without using Object.freeze but it only performs makes the object immutable shallowing, you have to roll your own deepFreeze if you would like to make the object truly immutable. So there are some practices you can do to make your functions and variables perform in a more immutable manner. [Read More]