Properly formatting JavaScript in JavaScript

冷暖自知 提交于 2019-12-14 02:31:54

问题


How can I automatically format JavaScript properly?

As an example, this:

(function(){(function(){alert('whatever')})()})()

Should become:

(function(){
    (function(){
        alert('whatever')
    })()
})()

回答1:


There is the jsbeautifier, you can find the source code at github.




回答2:


Try http://jsbeautifier.org/ - it's the same one used by jsfiddle.net on their "Tidy Up" button where you can try it out.



来源:https://stackoverflow.com/questions/10366985/properly-formatting-javascript-in-javascript

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!