1
function makeHelpCallback(help) {
  return function() {
    showHelp(help);
  };

//array elements here

  for (var i = 0; i < helpText.length; i++) {
    var item = helpText[i];
    document.getElementById(item.id).onfocus = makeHelpCallback(item.help);
}

I am having trouble understanding the last line. I have never seen the equal sign used in that way,

1 Answers1

6

I have never seen the equal sign used in that way

It assigns the return value of a function call (another function in this case; they are first class objects so can be passed around) to a property of an object.

Quentin
  • 914,110
  • 126
  • 1,211
  • 1,335