โจclosure: to close over or not
JS โฉ value โฉ function โฉ closure โฉ example โฉ to close over or notโ
- replit๏ผto close over or not? 
// โข returns a closure
// โข parameters are closed over
function GetInfo(id, name, grade) {
    // โญ closure
    // although `id`, `name`, `grade` are not mentioned explicitly,
    // these parameters are still being closed over by the closure.
    return function getInfo(whichValue) {
        // โญ eval('id') returns `id`, etc ...
        return eval(whichValue);
    };
}
const info = GetInfo(73, "Suzy", 87);
info("name"),    // Suzy
info("grade"),   // 87Last updated
Was this helpful?