Function Scope

In this lesson, we'll explain the behavior of functions and their scopes.

Inside the Function Body

In Reason, data created inside the body of a function will not exist outside it. Only the value we return is accessible. For example, this code will produce an error:

Press + to interact
let a = 10;
let b = 5;
let product = (a, b) => {
let c = 20;
a * b * c;
};
/* Accesing c outside the function */
c;

Redefining a Function

Because of let bindings, we can use the same identifier to define different functions. The latest definition will be ...