简体   繁体   English

JSFiddle.net我正确使用了吗?

[英]JSFiddle.net Am I using this correctly?

I put this code in the JavaScript box on www.jsfiddle.net and hit "run," but nothing happened. 我将此代码放在www.jsfiddle.net上的JavaScript框中,然后单击“运行”,但没有任何反应。 It works fine when I test it in Firebug, so why not jsfiddle.net Am I using jsfiddle.net incorrectly? 当我在Firebug中对其进行测试时,它可以正常工作,所以为什么不使用jsfiddle.net?

String.prototype.reverse = function() {
return Array.prototype.reverse.apply(this.split('')).join('');
}

"box".reverse();

Here I'm trying to save a fiddle. 在这里,我试图保存一个小提琴。 I click run and it doesn't work. 我单击运行,它不起作用。

http://jsfiddle.net/mjmitche/qnjP3/ http://jsfiddle.net/mjmitche/qnjP3/

Well, try alert("box".reverse()) ; 好吧,尝试alert("box".reverse()) ; Your code did work, there was nothing to show it. 您的代码确实有效,没有任何内容可显示。 See this fiddle 看到这个小提琴

Works fine for me : http://jsfiddle.net/jomanlk/Vp5SF/ 对我来说很好用: http : //jsfiddle.net/jomanlk/Vp5SF/

You probably didn't put an alert around your string. 您可能没有在字符串周围发出警报。 Since right now your method only returns the string so you don't have any indication that anything is happening. 从现在开始,您的方法仅返回字符串,因此您没有任何迹象表明正在发生任何事情。

Well, you have to create some output, don't you? 好吧,您必须创建一些输出,不是吗?

jsfiddle is not a JavaScript console. jsfiddle不是JavaScript控制台。 Either append the output do the DOM or print it to the browser's console. 附加输出以执行DOM或将其打印到浏览器的控制台。

jsfiddle lets you create a website with HTML, JavaScript and CSS on the fly, but nothing more. jsfiddle允许您即时创建具有HTML,JavaScript和CSS的网站。 If you put your code above in a basic HTML file and open it with your browser, you would not see any output either. 如果将代码放在基本的HTML文件中,然后使用浏览器将其打开,则也不会看到任何输出。

It might be helpful to read the documentation . 阅读文档可能会有所帮助。

Being a bit green with JS, I had the same notion about JSFiddle ... 对JS有点绿色,我对JSFiddle也有相同的看法...

Here's a tool that suits a bit better for that IMO ... jsbin.com (I took the liberty of putting your code in the above example). 这是一个更适合IMO ... jsbin.com的工具 (我在上面的示例中放了您的代码的自由)。

The benefit is that you can use console in jsbin :). 好处是您可以在jsbin :)中使用控制台。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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