Skip to content

Instantly share code, notes, and snippets.

@johnmurch
Created August 14, 2020 02:50
Show Gist options
  • Save johnmurch/75501237a320a4bef86e987d5d7deef3 to your computer and use it in GitHub Desktop.
Save johnmurch/75501237a320a4bef86e987d5d7deef3 to your computer and use it in GitHub Desktop.
params
var myurl = "journey?reference=123&line=A&destination=China&operator=Belbo&departure=1043&vehicle=ARC";
var keyval = myurl.split('?')[1].split('&');
for(var x=0,y=keyval.length; x<y; x+=1)
console.log(keyval[x], keyval[x].split('=')[0], keyval[x].split('=')[1]);
/*
reference=123 reference 123
line=A line A
destination=China destination China
operator=Belbo operator Belbo
departure=1043 departure 1043
vehicle=ARC vehicle ARC
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment