- use a tool that converts your newer code into older code equivalent
- ES6 adds a feature called "default parameter values." Transpiling will modify/add the code to work with ES5
- Example:
// IN ES6, USE A DEFAULT VALUE
function foo(a = 2) {
console.log( a );
}
// PRE ES6 EXPLICITLY CHECK FOR A DEFAULT VALUE AND DEFINE IT
function foo() {
var a = arguments[0] !== (void 0) ? arguments[0] : 2;
console.log( a );
}
- A common transpiler is Traceur