[JavaScript]如何实现一个JS脚本能在browser和NodeJs里都是用
2024-10-19 22:20:05
下面是一个Common的Solution
'use strict'; // Universal Module Definition (UMD) to support AMD, CommonJS/Node.js,
// Rhino, and plain browser loading.
if (typeof define === 'function' && define.amd) {
...
} else if (typeof exports !== 'undefined') {
...
} else {
...
}
最新文章
- spring配置文件
- JVM配置
- Don't Block on Async Code【转】
- 2014牡丹江网络赛ZOJPretty Poem(暴力枚举)
- KNN算法与Kd树
- 显示段落p中的前半部分内容 剩下的用三个点代替,点击更多时显示所有内容
- 9.css背景
- android常见错误-The container 'Android Dependencies' references non existing library
- oracle之分组内的字符串连接
- shell中的declare命令
- bzoj千题计划252:bzoj1095: [ZJOI2007]Hide 捉迷藏
- spring boot 自定义sql分页查询
- DataSnap 多层返回数据集分析FireDAC JSON
- 英语口语练习系列-C10-up and down
- angular4 富文本编辑器
- forEach 如何提前终止 跳出运行
- v$instance如何生成
- USER 版本与ENG 版本差异
- libpcap详解
- SQL SERVER 扩展属性的操作方法
热门文章
- java常用八大排序法
- java GC是在什么时候,对什么东西,做了什么事情?
- Anaconda 安装教程(Win10环境) Tensorflow安装
- MyBatis中动态SQL语句完成多条件查询
- 玩转Jquery
- sh 脚本重启/更新 Tomcat 项目
- Arduino Uno 在win7 64位下的驱动问题
- Codeforces #536 div2 E (1106E)Lunar New Year and Red Envelopes (DP)
- Spring_01 spring容器、控制反转(IOC)、依赖注入(DI)
- HDOJ 4802 GPA