javascript 注释_JavaScript中的注释

javascript 注释_JavaScript中的注释javascript 注释 Likeotherpro inJavaScript Wheneverwewa documentfrom

javascript 注释

Like other programming languages, in JavaScript comments can be used to prevent the execution of the statements. Whenever we want to ignore the statements or any text/document from execution, we use comments.

像其他编程语言一样, JavaScript注释可用于阻止执行语句。 每当我们想要忽略语句或执行中的任何文本/文档时,我们都会使用注释。

For example: While writing the code, sometimes the logic is complex and we want to explain in our words so that we can understand the logic – we can put the explanation in the comments.

例如:在编写代码时,有时逻辑很复杂,我们想用文字解释,以便我们可以理解逻辑–可以将解释放在注释中。

There are two types of comments in JavaScript:

JavaScript有两种类型的注释

  1. Single line comment

    单行注释

  2. Multi line comments

    多行注释

JavaScript单行注释 (JavaScript single line comment)

For single line comment in JavaScript, we use double slash characters (//) before the text/code. The code/text written after the double slash (//) will be ignored by the interpreter.

对于JavaScript中的单行注释,我们在文本/代码之前使用双斜杠(//)。 解释器将忽略双斜杠(//)之后编写的代码/文本。

Syntax:

句法:

 //This text will not be executed/ interpreted  

Example:

例:

  

Output

输出量

This is line1 This is line3 This is line5  

JavaScript多行注释 (JavaScript multi line comment)

Multi-line comments can be placed between /* and */. The comment starts with /* and terminates with */. We can place any number of lines between these comment characters.

多行注释可以放在/ *和* /之间。 注释以/ *开头,以* /结束。 我们可以在这些注释字符之间放置任意数量的行。

Syntax:

句法:

 /* This line will not be executed/ interpreted This line will also not be executed/ interpreted This line will also not be executed/ interpreted */  

Example:

例:

  

Output

输出量

This is line1 This is line4 This is line8 This is line9  

在语句中注释代码 (Comment the code in a statement)

We can comment on any code in a statement by using multi-line characters.

我们可以使用多行字符对语句中的任何代码进行注释。

Example:

例:

  

Output

输出量

This is line1 This is line2 Hello world result: 8  

翻译自: https://www.includehelp.com/code-snippets/comments-in-javascript.aspx

javascript 注释

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/219749.html原文链接:https://javaforall.net

(0)
上一篇 2026年3月17日 下午9:58
下一篇 2026年3月17日 下午9:59


相关推荐

  • visio2013首要事项闪退_visio一保存就闪退

    visio2013首要事项闪退_visio一保存就闪退问题描述visio2013安装完成后,新建流程图或者打开流程图,程序就会自动关闭,为了找到错误,我们打开“控制面板->事件查看器->windows事件日志”可以看到一个错误日志,错误如下:错误应用程序名称:VISIO.EXE,版本:15.0.4420.1017,时间戳:0x506742a9错误模块名称:VISLIB.dll,版本:15.0.4420.1017,时间戳:0x506741bc异常代码:0xc0000005错误偏移量:0x000000000010a887错

    2025年11月10日
    5
  • notifyDataSetChanged无效[通俗易懂]

    notifyDataSetChanged无效[通俗易懂]一、前言相信很多人都曾经被这个问题困扰,当然我也是这样过来的,原来以为只要数据变了,调用adapter的notifyDataSetChanged就会更新列表,然而结果却没有实现,其实是在一些细节上没有注意造成的,所以现在对这个问题进行下总结希望可以帮助到有需要的人。二、原因分析有以下三个原因:1、数据源没有更新,调用notifyDataSetChanged无效。2、数据源更新了,但是它指向新的引用,

    2022年6月28日
    71
  • char与byte的区别

    char与byte的区别很多初学者 包括我 已经学了一年多 java 了 肯会对 char 和 byte 这两种数据类型有所疑惑 相互混淆 今天特地查了好多资料 对 byte 和 char 两种数据类型进行了总结和比较 先将结果与大家分享 nbsp nbsp nbsp nbsp byte nbsp 是字节数据类型 nbsp 是有符号型的 占 1 nbsp 个字节 大小范围为 128 127 char nbsp 是字符数据类型 nbsp 是无符号型的 占 2 字节 Unicode 码 nbsp 大小范围 nbsp 是 0 65

    2025年7月5日
    5
  • pycharm没有setting_pycharm怎么配置python环境变量

    pycharm没有setting_pycharm怎么配置python环境变量问题:pycharm无法加载pip3安装包报错:pythonpackingtoolsnotfound.installpackingtools通过卸载重装pip3都没有用解决方法:更新一下setuptools就好啦sudopip3installsetuptools–upgradesudopipinstallsetuptools–upgrade…

    2022年8月27日
    10
  • OpenClaw实战一|企业微信AI客服数字员工:自动应答+工单创建+数据统计,零代码3天落地

    OpenClaw实战一|企业微信AI客服数字员工:自动应答+工单创建+数据统计,零代码3天落地

    2026年3月14日
    2
  • git初次登陆使用

    git初次登陆使用git初次登陆使用一.安装git二.在当前项目根目录点击鼠标右键,出来下图:点击进入git命令行界面。三.初始化项目四.添加所有文件到项目中五.尝试提交所有文件我由于是第一次连接

    2022年7月3日
    27

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号