如何让别人喜欢你的代码

良好的编码习惯是编程人员的基本素养,有利于后期人员的维护和查看。

毕竟大家都喜欢美女和靓仔

目录

js函数注释规范

案例

其他

推荐链接


js函数注释规范

|---------|-----|--------------------|
| 常用符号 | 说明 | 用法 |
| @param | 参数 | @param {type} name |
| @return | 返回值 | @return {type} |

案例

javascript 复制代码
/**
 * 测试
 * @param {number} num
 * @return {void}
 */
function test(num) {
  console.log(num);
}

其他

javascript 复制代码
@api: 提供给第三方使用的接口
@author: 标明作者
@param: 参数
@return: 返回值
@todo: 待办
@version: 版本号
@inheritdoc: 文档继承
@property: 类属性
@property-read: 只读属性
@property-write: 只写属性
@const: 常量
@deprecated: 过期方法
@example: 示例
@final: 标识类是终态, 禁止派生
@global: 指明引用的全局变量
@static: 标识类、方法、属性是静态的
@ignore: 忽略
@internal: 限内部使用
@license: 协议
@link: 链接,引用文档等
@see: 与 link 类似, 可以访问内部方法或类
@method: 方法
@package: 命名空间
@since: 从指定版本开始的变动
@throws: 抛出异常
@uses: 使用
@var: 变量
@copyright: 版权声明

推荐链接

1.京东凹凸实验室前端代码规范,网址:[https://guide.aotu.io/](http://link.zhihu.com/?target=https%3A//guide.aotu.io/ "https://guide.aotu.io/")(https://guide.aotu.io/)

2.腾讯前端代码规范,网址:[http://tgideas.qq.com/doc/index.html](http://link.zhihu.com/?target=http%3A//tgideas.qq.com/doc/index.html "http://tgideas.qq.com/doc/index.html")(http://tgideas.qq.com/doc/index.html)

3.百度前端代码规范文档,网址:[https://github.com/ecomfe/spec](http://link.zhihu.com/?target=https%3A//github.com/ecomfe/spec "https://github.com/ecomfe/spec")(https://github.com/ecomfe/spec)

4.JavaScript Standard Style,网址:[https://github.com/standard/standard](http://link.zhihu.com/?target=https%3A//github.com/standard/standard "https://github.com/standard/standard")(https://github.com/standard/standard)

5.Vue官方特有的代码风格指南, 网址:[https://cn.vuejs.org/v2/style-guide/index.html](http://link.zhihu.com/?target=https%3A//cn.vuejs.org/v2/style-guide/index.html "https://cn.vuejs.org/v2/style-guide/index.html")(https://cn.vuejs.org/v2/style-guide/index.html)

6.阮一峰的ES6编程风格,网址:[http://es6.ruanyifeng.com/#docs/style](http://link.zhihu.com/?target=http%3A//es6.ruanyifeng.com/%23docs/style "http://es6.ruanyifeng.com/#docs/style")(http://es6.ruanyifeng.com/#docs/style)

7.《代码整洁整洁之道》,网址:[https://item.jd.com/12812626.html](http://link.zhihu.com/?target=https%3A//item.jd.com/12812626.html "https://item.jd.com/12812626.html")(https://item.jd.com/12812626.html)

8.ESLint ,网址:[https://eslint.bootcss.com/](http://link.zhihu.com/?target=https%3A//eslint.bootcss.com/ "https://eslint.bootcss.com/")(https://eslint.bootcss.com/)

9.Prettier,网址:[https://prettier.io/](http://link.zhihu.com/?target=https%3A//prettier.io/ "https://prettier.io/")(https://prettier.io/)

相关推荐
星空椰6 小时前
Python 面向对象高级:继承与类定义详解
开发语言·python
kyriewen6 小时前
微软用Go重写TypeScript编译器,速度提升10倍,网友:这是“背叛”还是“救赎”?
前端·typescript·ecmascript 6
白露与泡影6 小时前
2026大厂Java面试题大全!牛客网最新版
java·开发语言
Ceelog6 小时前
久坐党自救指南:屏幕前 8 小时,身体到底在经历什么
前端·后端
凯瑟琳.奥古斯特6 小时前
高阶子查询题目精炼
开发语言·数据库·python·职场和发展·数据库开发
西陵6 小时前
Agent 为什么会陷入 Doom Loop?OpenClaw 的破解之道
前端·人工智能·ai编程
雪度娃娃7 小时前
转向现代C++——在意为改写的函数添加 override
开发语言·c++
Hyyy7 小时前
普通前端续命周报——第2周
前端
swipe7 小时前
DeepAgents 实战:用多 Agent 架构搭一个深度调研助手
javascript·面试·llm
wuxinyan1237 小时前
工业级大模型学习之路030:Streamlit 企业级智能体前端工作台
前端·学习·streamlit·智能体