I have the following function.
alias.writeDialogue = function() { return writeDialogue(...arguments); }; I wish to support IE, which doesn't support the spread operator. With what should I replace ...?
Use apply to transform an array of arguments into an argument list:
return writeDialogue.apply(undefined, arguments); But it would be better to integrate Babel into your build process, so that you can write with modern syntax and have it transpiled into ES5-compatible syntax automatically. For example
Plug in
alias = { writeDialogue: function() { return writeDialogue(...arguments); } } and you get
"use strict"; alias = { writeDialogue: function (_writeDialogue) { function writeDialogue() { return _writeDialogue.apply(this, arguments); } writeDialogue.toString = function () { return _writeDialogue.toString(); }; return writeDialogue; }(function () { return writeDialogue.apply(undefined, arguments); }) }; Babel will also automatically transpile arrow functions, const and let, async/await (with RegeneratorRuntime), and so on. It's a must-have.
alias.writeDialogue = writeDialogue?alias.x = xalso return what x returns? EDIT: Yes it will.