当前位置:网站首页>Interrupt array Foreach method [js implementation]
Interrupt array Foreach method [js implementation]
2022-06-23 03:00:00 【It workers】
Realization principle
There is no built-in method to implement interrupts forEach, If we want to implement interrupts forEach, We can do this by throwing an exception .
Implementation code
var BreakException = {};
try {
[1, 2, 3].forEach(function(el) {
console.log(el);
if (el === 2) throw BreakException;
});
} catch (e) {
if (e !== BreakException) throw e;
}边栏推荐
- Use ES6 new Target to simulate abstract classes
- Markdown - enter a score (typora, latex)
- Hypervisor Necromancy; Recover kernel protector (1)
- [SaaS examination certification] apaas_ Tencent Qianfan magic pen
- New uniapp+uniui background management uniuadmin
- How PHP uses redis
- Cve-2021-4034 reappearance
- Soft exam information system project manager_ Information system comprehensive testing and management - Senior Information System Project Manager of soft test 027
- Reinforcement learning series (IV) -policygradient example
- Optimization method of live weak network
猜你喜欢

Soft exam information system project manager_ Contract Law_ Copyright_ Implementation Regulations - Senior Information System Project Manager of soft exam 030

How to store, manage and view family photos in an orderly manner?

Spark broadcast variables and accumulators (cases attached)

6. template for integer and real number dichotomy

Soft exam information system project manager_ Information system comprehensive testing and management - Senior Information System Project Manager of soft test 027

C language series - Section 4 - arrays

5. concept of ruler method

Vulnhub DC-5
What is sitelock? What is the function?

8. greed
随机推荐
Pytest common summary
Call rest port to implement nailing notification
Reading redis source code (VI) multi threading of redis 6.0
51. numerical arrangement
Extract NTDs with volume shadow copy service dit
How to store, manage and view family photos in an orderly manner?
Source code analysis | activity setcontentview I don't flash
Vs code remote SSH configuration
[target tracking] open source | polytrack: use boundary polygons to quickly track and segment multiple targets, instead of bounding box and mask tracking
Integrated solution for intelligent supply chain platform management in rubber industry
Capture passwords of all chrome versions
Wi Fi 6 is coming - larger capacity, lower latency, faster network speed and more security
Reinforcement learning series (III) -gym introduction and examples
Wechat applet camera compressed image is Base64
How to make a borrowing card
JS event delegation (event agent)
JS event bubble and event capture
Autowired usage
A bit about the state machine (FSM SMR DFSM)
How to gracefully solve the problem of platform font adaptation