简体   繁体   中英

How do I run a javascript code

我已经获得了要运行的代码以进行分析,但我找不到在哪里运行,我尝试了google chrome,但是这让我感到困惑,我的朋友告诉我注意加号,但是我不确定如何打开它或如果可以的话,谢谢您的帮助

You can run it in the chrome dev tools console, or use something like https://repl.it/languages/javascript or https://jsfiddle.net/

Hope this helps.

You can use Ctrl+Maj+J to directly go to the javascript console where you can paste that code.

You can also run it by using NodeJs

However, you really should avoid running random code unless you know what it's doing.

在chrome上,按F12键,然后打开Tab控制台,您可以在此处测试代码

I suppose what you are asking is not how to run it, but how to learn it. Notepad++ is an editor you may use to write your code, then you can view and debug it in approximately any browser. Have a look on how to start learning JavaScript

You have 2 options to run a js code: Nodejs and any browser you want(I suggest google-chrome) Option 1(Nodejs):
First you must install nodejs. There are tons of tutorials on the net. Then open cmd/terminal and navigate to the javascript file. Then type node filename.js .
Option 2(browser):
first create an index.html file in the directory where the .js file is located. Then open it with any text editor(I suggest brackets ) and enter the following code:

<!DOCTYPE html>
    <html>
        <head></head>
        <body>
            <script src="filename.js"></script>
        </body>
    </html>

Now save the file and close the editor. Click with the right button on the html file and the choose open with->google-chrome. If the js file have console.logs the press f12 while in the browser.

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