Given this Javascript:
String.method('deentityify', function () {
// The entity table. It maps entity names to
// characters.
var entity = {
quot: '"',
lt: '<',
gt: '>'
};
// Return the deentityify method
return function () {
return this.replace(/&([^&;]+);/g,
function (a, b) {
var r = entity[b];
return typeof r === 'string' ? r : a;
}
);
};
}());
document.writeln('<">'.deentityify());
What goes into the last function as a and b, and why?
I get that we're splitting up the string I'm passing in into 3 groups, but I don't understand why < is going into a and why just lt is going into b.