Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@nealalan
Created August 6, 2019 00:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nealalan/4630a21cdedbc0b34f03254bc539951c to your computer and use it in GitHub Desktop.
Save nealalan/4630a21cdedbc0b34f03254bc539951c to your computer and use it in GitHub Desktop.
JavaScript Transpiling

TRANSPILING

  • 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 );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment