How to write readable Javascript

若如初见. 提交于 2019-12-05 09:42:15

I bet you should just follow already established coding standards.

You may follow coding standard for one of two best JavaScript frameworks:

Basically use tabs instead of spaces (this may be difficult for some, but I believe is established standard for JS), avoid unnecessary spaces (eg. in ) { in function definition space is not welcome and should probably look like: ){), etc.

PS. It is my personal > opinion < that MooTools & jQuery are 2 the best JS frameworks.

You need to format your code in order to be readable. And always while typing JS use IDE features to format code and each new command put into new row. Then you won't have a problems.

You can use Online JavaScript beautifier for your existing javascript.

http://en.wikipedia.org/wiki/Indent_style http://en.wikipedia.org/wiki/Coding_conventions

Are a good place to start. I personally use the K&R style for clarity. When it comes down to it though all you need to do is find a style you like and stick with it. Consistency ;]

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