Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8578029
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T20:17:40+00:00 2026-06-11T20:17:40+00:00

Using chrome 21 and prototype 1.7.1, I have discovered that using throw $break does

  • 0

Using chrome 21 and prototype 1.7.1, I have discovered that using throw $break does not work.

The Error gets thrown up to the browser when it should have been stopped by

if (e != $break) { ... }

I suspect that this occurs because inject has a native implementation in Chrome, and it does not get wrapped by the same functionality as the other built-in functions.

Am I correct when assuming this, or is there something wrong with my code?

Code to re-create:

var a = [1,2,3,4,5,6,7,9].inject([], function(arr, e) {
    console.log(e);
    if (e === 5) {
        throw $break;
    }

    arr.push('Done ' + e);
    return arr;
});
console.log('Final Array : ' + a)

update

just tested with Firefox 14 and IE 9, the same error presents itself..

​update (2015)

This seems to be fixed by 1.7.3, tested with Chrome 45.0.2454.101

Verified by checking the source, reduce was removed

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T20:17:41+00:00Added an answer on June 11, 2026 at 8:17 pm

    The problem is that as of Prototype 1.7.1, Array#inject has two implementations, and they behave differently. (This is Not Goodtm.) It’s a breaking change between Prototype 1.7.1 and 1.7.0, as we can see using this fiddle vs. this one.

    If the native Array object has the reduce function from ES5, Array#inject uses it — without handling $break — whereas if it doesn’t, Array#inject is implemented via Enumerable#inject, which uses Enumerable#each, which handles $break.

    You can see this if you search the Prototype 1.7.1 source. First you find the non-reduce version in Enumerable, then you find the reduce version further down in the Array stuff, and you see that the Array version grabs the Enumerable version if reduce isn’t there.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using prototype.js for my web app, and I have everything running on Chrome,
Problem I have a custom tab control using Chrome-shaped tabs that binds to a
I want to notify an user using Chrome browser. I need something powerful like
Note: I'm using Google Chrome Currently I have this test page http://www.evecakes.com/doodles/canvas_size_issue.htm It should
I have a user script (for chrome and FF) that adds significant functionality to
Question update: I have figured out that importing JQuery (even without using it at
So I have an app that submits a form to an external cart using
I most likely have the same problem as in this question: Weird Chrome prototype/jQuery
i have a strange problem only in Chrome using an iframe but working in
I'm using chrome devtools network API and the following code but always the alert

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.