Recently, I read the ECMAScript Language Specification. I didn't plan to read the whole specification, I just picked up some parts. I came cross many questions, one of them is like this:
1.Let len be ToInteger(argument).
2.ReturnIfAbrupt(len).
3.If len ≤ +0, then return +0.
4.Return min(len, 2^53-1).
As I understand, it should be like this:
var len = ToInteger(argument); // step 1
len = ReturnIfAbrupt(len);// step 2
// step 3
if(len<=0){
return +0; //-0 is OK too?
}
return Math.min(len, Math.pow(2,53)-1); // step 4
I didn't understand what the meaning of ReturnIfAbrupt(len) is, and I found this:
1.If argument is an abrupt completion, then return argument.
2.Else if argument is a Completion Record, then let argument be argument.[[value]].
What is abrupt completion, and the differents between it and Completion Record?Can they combine one step:If argument is an Completion Record, then return argument.Any suggestion will be gratefull!