Home  >  Article  >  Web Front-end  >  javascript中的注释使用与注意事项小结_javascript技巧

javascript中的注释使用与注意事项小结_javascript技巧

WBOY
WBOYOriginal
2016-05-16 18:01:531197browse

在javascript中有两种注释方式:

单行注释: //

多行注释: /* */

注释主要是为了让我们编写的程序更具有可读性,也便于他人来进行二次修改

看下面的例子,我们给正则表达式用/* */注释了,运行时发布报了一个语法错误

复制代码 代码如下:

/*
var rm_a = /a*/.match(s);
*/

所以说块级注释是不安全的,如果在我们的代码中犯了这样的错误,很难去排查

所以最好是用单选注释// 取代多行注释 /* */

JavaScript 注释
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn