Skip to content

Instantly share code, notes, and snippets.

@psiphi75
Created February 14, 2017 21:33
Show Gist options
  • Save psiphi75/41417135e9ee82192a8d5a65993e4d19 to your computer and use it in GitHub Desktop.
Save psiphi75/41417135e9ee82192a8d5a65993e4d19 to your computer and use it in GitHub Desktop.
Example of polymorphic and monomorphic code
function add(a, b) {
return a + b;
}
add(1, 2); // Starts as monomorphic
add(2, 3); // Still monomorphic
add('x', 'y'); // Now becomes polymorphic - bad for optimisation
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment