Skip to content

Instantly share code, notes, and snippets.

@samueljoli
Created January 30, 2017 17:57
Show Gist options
  • Save samueljoli/d0af87ff77ec4193c3172bb59527baa0 to your computer and use it in GitHub Desktop.
Save samueljoli/d0af87ff77ec4193c3172bb59527baa0 to your computer and use it in GitHub Desktop.
//javascript... NOT assembler... that would take too long:
var jumpAddressTable = new Array;
jumpAddressTable[0] = function (){ console.log('I like 0')};
jumpAddressTable[1] = function (){ console.log('This is an arbitrary function')};
jumpAddressTable[2] = function (){ console.log('2 is the smallest non-negative prime number')};
jumpAddressTable[3] = function (){ console.log('One more for the show')};
var switchVal = 2;
jumpAddressTable[switchVal]();
//would print '2 is the smallest non-negative prime number'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment