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

  • Home
  • SEARCH
  • 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 8723053
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T07:32:30+00:00 2026-06-13T07:32:30+00:00

I’m currently implementing some shims for the ES6 draft. I’m wondering if anyone can

  • 0

I’m currently implementing some shims for the ES6 draft. I’m wondering if anyone can tell me what ReturnIfAbrupt means. For instance, my implementation for Number.toInt (which calls internal [[ToInteger]] is as follows:

if (!('toInt' in Number))
    Object.defineProperty(Number, 'toInt', {

        value: function toInt(value) {
            // ECMA-262 Ed. 6, 9-27-12. 9.1.4

            // 1. Let number be the result of calling ToNumber on the input argument.
            var number = Number(value);

            // 2. ReturnIfAbrupt(number).
            // ?

            // 3. If number is NaN, return +0.
            if (number != number) return 0;

            // 4. If number is +0, -0, +Infinity, or -Infinity, return number.
            if (number == 0 || 1 / number == 0) return number;

            // 5. Return the result of computing sign(number) * floor(abs(number)).
            return (n < 0 ? -1 : 1) * Math.floor(Math.abs(number));

        },

        writable: true,
        configurable: true

    });

Step 2 is ReturnIfAbrupt(number). You’ll notice I currently have // ? for that step because I’m not sure what to do. What does it mean when it says ReturnIfAbrupt(...)?

I have read the section on ReturnIfAbrupt in the draft, however I am unable to understand what to do for step 2, what to put in place of // ? in the code above.

From my reading, it may be that nothing should be done, and the ReturnIfAbrupt step merely means to let any error which occurred in ToNumber to propagate up, exiting the function. However, that seems overly verbose, as I would think it could go without saying. Also, it doesn’t seem to me like ToNumber can even throw an error. Could someone confirm or help me to understand the real meaning?

  • 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-13T07:32:31+00:00Added an answer on June 13, 2026 at 7:32 am

    ReturnIfAbrupt is referring to an Abrupt Completion. A completion record contains a type and the value associated with it. A normal completion would be something like an expression’s resulting value. A return completion from a function is the usual expected completion aside from a normal completion. Any other completion types are abrupt. That’s throw, break, continue.

    if (isCompletionRecord(v)) {
      if (isAbruptCompletion(v)) {
        return v;
      } else {
        v = v.value;
      }
    }
    

    Implementing it as you are, what it would entail is wrapping the function in a try catch. A thrown value would be an abrupt completion. This isn’t something you see at the JS level though, it’s for implementing control flow and non-local control transfers at the engine level.

    I’ve implemented much of the ES6 spec in a JS virtual machine that may also help shed some light on it, here’s ToInteger: https://github.com/Benvie/continuum/blob/master/lib/continuum.js#L516

    function ToInteger(argument){
      if (argument && typeof argument === OBJECT && argument.IsCompletion) {
        if (argument.IsAbruptCompletion) {
          return argument;
        }
        argument = argument.value;
      }
      return ToNumber(argument) | 0;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Does anyone know how can I replace this 2 symbol below from the string
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a jquery bug and I've been looking for hours now, I can't
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I want use html5's new tag to play a wav file (currently only supported
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I am currently running into a problem where an element is coming back from
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example

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.