). ▁ ▁# ▁Define ▁the ▁table ▁using ▁one ▁anonymous ▁code - ref ▁and ▁one ▁named ▁code - ref ▁my ▁% dispatch ▁= ▁( ▁▁▁▁ ▁"- h " ▁=> ▁sub ▁{ ▁ ▁return ▁" hello \ n "; ▁}, ▁▁▁▁ ▁"- g " ▁=> ▁\ & say _ good bye ▁); ▁▁ ▁sub ▁say _ good bye ▁{ ▁▁▁▁ ▁return ▁" good bye \ n "; ▁} ▁▁ ▁# ▁F etch ▁the ▁code ▁ref ▁from ▁the ▁table , ▁and ▁invoke ▁it ▁my ▁$ sub ▁= ▁$ dispatch {$ AR GV [ 0 ] }; ▁print ▁$ sub ▁? ▁$ sub -> () ▁: ▁" unknown ▁argument \ n "; ▁ ▁Running ▁this ▁Perl ▁program ▁as ▁perl ▁gre et ▁- h ▁will ▁produce ▁" hello ", ▁and ▁running ▁it ▁as ▁perl ▁gre et ▁- g ▁will ▁produce ▁" good bye ". ▁ ▁JavaScript ▁implementation ▁ ▁Following ▁is ▁a ▁demo ▁of ▁implementing ▁dispatch ▁table ▁in ▁JavaScript : ▁var ▁things We Can Do ▁= ▁{ ▁▁▁▁ ▁do This Th ing ▁▁▁▁▁ ▁: ▁function () ▁{ ▁/* ▁behavior ▁*/ ▁}, ▁▁▁▁ ▁do That Th ing ▁▁▁▁▁ ▁: ▁function () ▁{ ▁/* ▁behavior ▁*/ ▁}, ▁▁▁▁ ▁do This Other Th ing ▁: ▁function () ▁{ ▁/* ▁behavior ▁*/ ▁}, ▁▁▁▁ ▁default ▁▁▁▁▁▁▁▁▁ ▁: ▁function () ▁{ ▁/* ▁behavior ▁*/ ▁} ▁}; ▁ ▁var ▁do Something ▁= ▁function ( do What ) ▁{ ▁▁▁▁ ▁var ▁thing To Do ▁= ▁things We Can Do . has O wn Property ( do What ) ▁? ▁do What ▁: ▁" default " ▁▁▁▁