I have array of 10 elements, I am mapping to extract array data . I want to stop array executing when compile reached to array index 5 . I know it possible with for loop but I need it in map function. Please help me
Related questions
Related questions
- The Overflow Blog
-
-
- Featured on Meta
-
-
-
Hot Network Questions
- Which objects in a topos such as the étale topos are "classifying spaces" of their fundamental groups?
- ASCII-based Lightweight Browser in Python with Clippy-Style Helper (Updated)
- Can military personnel disobey illegal orders under U.S. law?
- What does Tolkien mean by "eating tea" in Letters from Father Christmas?
- Nullable warning when upgrading to extension-members syntax
- Handling client integrity for closed/opensource mixed project
- Typesetting a more aesthetic continued fraction
- How to design a distributed system with an event broker where strong ordering is required?
- Could there be a circular flux tube in superconductors?
- Can you store a summoning spell in a Glyph of Warding?
- What does it mean to not know something you should know?
- Is there a loophole in Bell's theorem because of our ignorance of the state of the measurement device?
- Do I have to transcribe all pronunciation details if I use the [] transcription?
- Command with `^^` and `__` as exponent optional arguments
- Can a Gazer using Telekinetic Ray throw a creature 30 feet up in the air?
- Staggered monitors: Mouse moving to other monitor where not abutting
- Origin of the Popular Distinction Between Morals and Ethics
- Vertical bars...or I mean...well, you'll get what I mean
- Can I delete the Chrome's OptGuideOnDeviceModel safely? It's taking up 4GB
- How to build basement walls in a basement that has a interior French drain and uneven epoxied perimeter?
- Why couldn't all assimilees be liberated from the Borg?
- Bethesda or Bethzatha in John 5:2?
- How can I clean unsealed concrete before installing flooring?
- Why are Jeremy Crawford's rules comments unreliable?
lang-js
mapcan't do that but you can achieve that withreduceorfilterreduceandfilter?sliceandmap?[1,2,3,4,5,6,7,8,9,10].map((x,i) => { if(i>=5) throw 0; console.log(x**2) })- however throw exception will slow down your code and they are not designed for break loops in normal situations