简体   繁体   中英

How do I run the code in the Airbnb javascript style guide?

I paste the following code

var foo = 1,
    bar = foo;

bar = 9;

console.log(foo, bar); // => 1, 9

onto JSFiddle and online JavaScript Interpreter but both are not showing anything after clicking run, how do I make it so they work?

If you're using Google Chrome, try the developer console. It's located in View > Developer > Javascript console . You can also try the web developer console on Firefox or the Firebug Console (if you have the firebug add-on in your Firefox installation, obviously).

console.log writes to the browser console. That is why in both the tool and jsfiddle you mentioned you see no output unless you open the browser console (try google for that: "open javascript console {your browser}")

In the online tool you listed there is a defined function writeln which writes to the textarea on the right side. You can therefore try this if you want to see output on the right side:

var foo = 1,
    bar = foo;

bar = 9;

writeln(foo); // => 1
writeln(bar); // => 9

On jsfiddle, there is no such function.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM