如何让别人喜欢你的代码

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

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

目录

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/)

相关推荐
集成显卡10 小时前
Rust实战七 |基于带 colored 颜色文字控制台的批量文件删除工具
开发语言·后端·rust
夜焱辰10 小时前
浏览器端 Agent 的文件版本管理:不用 Git,基于 OPFS + SQLite 自己造了一个
前端·人工智能
梦想的颜色10 小时前
TypeScript 完全指南(下):从类型体操到生产级配置
前端·javascript·typescript
比昨天多敲两行11 小时前
linux 线程概念与控制
java·开发语言·jvm
huaweichenai11 小时前
php 根据每个类型的抽签范围实现抽签功能
开发语言·php
Hi~晴天大圣12 小时前
npm使用介绍
前端·npm·node.js
codeejun12 小时前
每日一Go-73、云原生成本优化 —— 资源限制 & 指标驱动扩容
开发语言·云原生·golang
888CC++13 小时前
如何在 C 语言中进行程序调试?
前端·javascript·算法
就叫_这个吧13 小时前
Java注解、元注解、自定义注解定义及应用
java·开发语言·注解
喵个咪13 小时前
基于 Taro 的 Headless CMS 多端前端架构:技术解析与二次开发导引
前端·react.js·taro