开发者

JSFiddle.net Am I using this correctly?

开发者 https://www.devze.com 2023-02-17 22:40 出处:网络
I put this code in the JavaScript box on www.jsfiddle.net and hit \"run,\" but nothing happened. It works fine when I test it in Firebug, so why not jsfiddle.netAm I using jsfiddle.net incorrectly?

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

String.prototype.reverse = function() {
retu开发者_运维百科rn 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/


Well, try 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/

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.com (I took the liberty of putting your code in the above example).

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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号