// • 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"), // 87