Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is a URL in the middle of a function not causing an error?

Tags:

javascript

By mistake, an URL was pasted into a JavaScript snippet. Reduced to a minimum, it looked roughly like this:

function(){
  /* a bunch of code */
  http://www.stackoverflow.com
  /* a bunch of code */
  return "it still works";
}

It was overlooked for quite some time, because it did not produce an error. Why is that? Why does this function still run without erroring?

like image 315
JustAPoring Avatar asked Apr 14 '14 16:04

JustAPoring


1 Answers

You're defining a label called http. The // in the url comments the rest out.

see: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/label

like image 156
SimpleJ Avatar answered Sep 23 '22 18:09

SimpleJ