Javascript 如何快速测试一些javascript代码?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/8869783/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to quickly test some javascript code?
提问by user705414
What would be a good way to test Javascript on a browser? Should there be a localhost in my computer? and how to create one?
在浏览器上测试 Javascript 的好方法是什么?我的计算机中应该有一个本地主机吗?以及如何创建一个?
回答by AlphaMale
Following is a free list of tools you can use to check, test and verify your JS code:
以下是可用于检查、测试和验证 JS 代码的免费工具列表:
Hope this helps.
希望这可以帮助。
回答by Aleksandrs Ulme
If you want to edit some complex javascript I suggest you use JsFiddle. Alternatively, for smaller pieces of javascript you can just run it through your browser URL bar, here's an example:
如果你想编辑一些复杂的 javascript,我建议你使用JsFiddle。或者,对于较小的 javascript,您可以通过浏览器 URL 栏运行它,这是一个示例:
javascript:alert("hello world");
And, as it was already suggested both Firebug and Chrome developer tools have Javascript console, in which you can type in your javascript to execute. So do Internet Explorer 8+, Opera, Safari and potentially other modern browsers.
而且,正如已经建议的那样,Firebug 和 Chrome 开发人员工具都有 Javascript 控制台,您可以在其中键入要执行的 javascript。Internet Explorer 8+、Opera、Safari 和其他可能的现代浏览器也是如此。
回答by Diode
Install firebug: http://getfirebug.com/logging. You can use its console to test Javascript code. Google Chrome comes with Web Inspector in which you can do the same. IE and Safari also have Web Developer tools in which you can test Javascript.
安装萤火虫:http: //getfirebug.com/logging。您可以使用它的控制台来测试 Javascript 代码。Google Chrome 带有 Web Inspector,您可以在其中执行相同的操作。IE 和 Safari 也有 Web Developer 工具,您可以在其中测试 Javascript。