admin管理员组

文章数量:1418593

I put this code in the JavaScript box on www.jsfiddle and hit "run," but nothing happened. It works fine when I test it in Firebug, so why not jsfiddle Am I using jsfiddle incorrectly?

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.

/

I put this code in the JavaScript box on www.jsfiddle and hit "run," but nothing happened. It works fine when I test it in Firebug, so why not jsfiddle Am I using jsfiddle incorrectly?

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/mjmitche/qnjP3/

Share Improve this question edited Mar 21, 2011 at 11:49 Leahcim asked Mar 21, 2011 at 11:44 LeahcimLeahcim 42.2k61 gold badges203 silver badges344 bronze badges 0
Add a ment  | 

4 Answers 4

Reset to default 3

Well, try alert("box".reverse()); Your code did work, there was nothing to show it. See this fiddle

Works fine for me : http://jsfiddle/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. Either append the output do the DOM or print it to the browser's console.

jsfiddle lets you create a website with HTML, JavaScript and CSS on the fly, but nothing more. If you put your code above in a basic HTML file and open it with your browser, you would not see any output either.

It might be helpful to read the documentation.

Being a bit green with JS, I had the same notion about JSFiddle ...

Here's a tool that suits a bit better for that IMO ... jsbin. (I took the liberty of putting your code in the above example).

The benefit is that you can use console in jsbin :).

本文标签: javascriptJSFiddlenet Am I using this correctlyStack Overflow