Below is an extract from my textbook.
I have a question about the use of [] here in window.history[type]()
. I can tell that it's separating the object name(window) and the variable(type) so that they can be recognized as separate things but is there a name for this use of []? I performed a google search but nothing came up.
$(function() {
//omitted
['back', 'forward'].forEach(function(type) {
$('.' + type).click(function() {
window.history[type]();
});
});
});