Learning Functional Programming with JavaScript - Anjana Vakil - JSUnconf
Why Stack Overflow recommends it
Stack Overflow users link it when explaining functional approaches to array transformations in JavaScript, and when introducing immutability and structural sharing.
Recommended by 3 people across 3 different months, 2016 to 2018.
What it is
A 30-minute conference talk from JSUnconf by Anjana Vakil on learning functional programming concepts using JavaScript. It covers ideas such as immutability, pure functions, and working with map, filter and reduce, with accompanying slides.
What people said
Recommends Yuri Pereira · 2016-09 · Stack Overflow · on “How to separate JSON array into 2 separate arrays of values with jQuery?”
A new solution that I've been using is the map [LINK] function. It is developed for functional programming, a better way to split the "trees", and much more understandable. Still learning but I recommend this video here [this video] . It's fully supported by ECMA 5. var Array1 = [ { "date": "2015-10", "clientCostsTotal": "0.00" }, { "date": "2015-11", "clientCostsTotal": "0.00" }, { "date": "2016-01", "clientCostsTotal": "0.00" }, { "date": "2016-02", "clientCostsTotal": "0.00" }, { "date": "2016-03", "clientCostsTotal": "0.00" }, { "date": "2016-04", "clientCostsTotal": "27962.50" }, { "date": "2016-05", "clientCostsTotal": "174060.00" }, { "date": "2016-06", "clientCostsTotal": "309000.00" }, {
Recommends Rico Kahler · 2017-08 · Stack Overflow · on “Why am I getting repeated values in the following JavaScript operation?”
I took a more functional approach. When you have a list of data that you need to transform to another list of data, I'm of the opinion that map , filter , and reduce are the way to go. This is a decent video that explains the idea [this video] Hope this was interesting. let openingTimes = { sunday: [{ id: 1, shift: 'morning', opening_time: '07:00', closing_time: '11:00' }, { id: 1, shift: 'day', opening_time: '13:30', closing_time: '16:30' }, { id: 1, shift: 'night', opening_time: '20:00', closing_time: '23:00' } ], monday: [{ id: 1, shift: 'day', opening_time: '13:30', closing_time: '16:30' }], wednesday: [{ id: 1, shift: 'morning', opening_time: '07:00', closing_time: '12:00' }, { id: 1, shift:
Recommends Boghyon Hoffmann · 2018-02 · Stack Overflow · on “How to add an object to an array”
@jdmayfield: But as you might have guessed already, creating new objects every time might become inefficient quickly when the objects get huge. For such cases, there are helpful libs, which make it efficient by leveraging persistent data structures, such as Mori [LINK] (kinda dead) and Immutable.js [LINK] . Here is a short introduction to "why immutability": [this video]
Cites MFave · 2017-10 · Stack Overflow · on “Javascript Object Assign and Structural Sharing”
I've been experimenting with concepts of immutability with javascript objects. I was wondering if the following code example implements what I believe is known as "Structural Sharing" (see: [this video] ). const objectFirst = { key1: 1, key2: 2 } const updateObject = (lastObject) => { const updatedObject = {...lastObject, ...{ key2: 4 }} // Object.assign({}, lastObject, { key2: 4 }) return updatedObject } const objectNext = updateObject(objectFirst) objectNext is now { key1: 1, Key2: 4 } and objectFirst is unchanged. But has key1 been duplicated? Or, is their now essentially a reference to key1's location in memory shared by both objects? I'm basically just asking if this approach implements some