javascript - why does is say - underscore is undefined -


why - '_' undefined, below basic simple example , fiddle. thank you

http://jsfiddle.net/fuefq/

-------------index.html--------------------------- <html> <head>      <title></title>          <script type="text/javascript" src="jquery.js"></script>         <script type="text/javascript" src="underscore.js"></script>              <script type="text/javascript" src="myjs.js"></script>         <head>        <html>      <body>       <script>      <button type="button" onclick = "loadthis();">click me!</button>        </script>      </body>  </html> 

-------------myjs.js---------------------------   var loadthis = function(){      vas x = _.uniq([1, 2, 1, 3, 1, 4]);      alert(x);  }; 

the problem fiddle loadthis contained within function jsfiddle provides (wrapping code), , error loadthis, not _, undefined. (if on left, you'll see have "onload" in second drop-down selected. means jsfiddle generates window.load callback , puts code in callback.) if fix this updated fiddle, works fine.

if you're seeing error in real code saying _ undefined, suggests haven't (successfully) loaded underscore.js. typically because didn't put script tag in, script tag misformed in way, or url in tag wrong. if in javascript console of browser (if browser doesn't have one, switch modern browser, will), show if url wrong.


Comments

Popular posts from this blog

android - getbluetoothservice() called with no bluetoothmanagercallback -

sql - ASP.NET SqlDataSource, like on SelectCommand -

ios - Undefined symbols for architecture armv7: "_OBJC_CLASS_$_SSZipArchive" -