当前位置:网站首页>函数只执行第一次的执行一次 once函数
函数只执行第一次的执行一次 once函数
2022-04-23 13:36:00 【万事胜意sy】
//只执行一次函数
function once(fn){
var ifFalse = true
return function(){
if(ifFalse){
ifFalse = false
fn()
}
}
}
//调用
function getName(){
console.log('我叫吉娃娃')
}
getName = once(getName)
getName() //'我叫吉娃娃'
getName() //不执行
转自链接:https://www.nowcoder.com/questionTerminal/42997185c50a45a08b64c253d2f1edc5?mutiTagIds=644&page=1&onlyReference=false
版权声明
本文为[万事胜意sy]所创,转载请带上原文链接,感谢
https://blog.csdn.net/weixin_50736511/article/details/124359171
边栏推荐
- Ai21 labs | standing on the shoulders of giant frozen language models
- TERSUS笔记员工信息516-Mysql查询(2个字段的时间段唯一性判断)
- ACFs file system creation, expansion, reduction and other configuration steps
- Publish custom plug-ins to local server
- 零拷貝技術
- Analysis of unused index columns caused by implicit conversion of timestamp
- Storage scheme of video viewing records of users in station B
- Launcher hides app icons that do not need to be displayed
- Processing of ASM network not automatically started in 19C
- Oracle generates millisecond timestamps
猜你喜欢
Leetcode brush question 897 incremental sequential search tree
Dolphin scheduler configuring dataX pit records
Detailed explanation of constraints of Oracle table
QT calling external program
校园外卖系统 - 「农职邦」微信原生云开发小程序
Leetcode? The first common node of two linked lists
Dolphin scheduler scheduling spark task stepping record
为什么从事云原生开发需要学习容器技术
Logstash数据处理服务的输入插件Input常见类型以及基本使用
零拷贝技术
随机推荐
Tangent space
Oracle RAC database instance startup exception analysis IPC send timeout
Longitude and latitude position of provincial capitals in China
面试官给我挖坑:单台服务器并发TCP连接数到底可以有多少 ?
Launcher hides app icons that do not need to be displayed
零拷貝技術
Android clear app cache
Usereducer basic usage
OSS cloud storage management practice (polite experience)
Analysis of cluster component gpnp failed to start successfully in RAC environment
JS time to get this Monday and Sunday, judge the time is today, before and after today
Double pointer instrument panel reading (I)
Analysis of unused index columns caused by implicit conversion of timestamp
Storage scheme of video viewing records of users in station B
JUC interview questions about synchronized, ThreadLocal, thread pool and atomic atomic classes
Plato farm, a top-level metauniverse game, has made frequent positive moves recently
Aicoco AI frontier promotion (4.23)
Dolphin scheduler configuring dataX pit records
Handling of high usage of Oracle undo
Analysis of redo log generated by select command