Hi Jon,
Chibee Patag Miranda

Hi Chibee,

Functions are first class citizens in JavaScript. Because we can treat a function like any other type (string, int, etc…) we can also store them in a data structure and call them like any type.

For example,

var foo = { “bar”: “baz” }

if I call foo[“bar”] I will get “baz”

I could also do

var foo = { “bar”: function(argA, argB) { return argA + “ “+ argB; } }

if I called foo again like so:

foo[“bar”](“hello”, “world”), it would return “Hello World”.

This pattern in redux avoids us having to write a switch statement. Every state transformation then becomes its own function.

Show your support

Clapping shows how much you appreciated Jon Lebensold’s story.