private static Object jsConstructor ( Context cx , Scriptable scope , Object [ ] args ) { if ( args . length == 0 ) return new NativeArray ( 0 ) ; // Only use 1 arg as first element for version 1.2; for // any other version (including 1.3) follow ECMA and use it as // a length. if ( cx . getLanguageVersion ( ) == Context . VERSION_1_2 ) { return new NativeArray ( args ) ; } Object arg0 = args [ 0 ] ; if ( args . length > 1 || ! ( arg0 instanceof Number ) ) { return new NativeArray ( args ) ; } long len = ScriptRuntime . toUint32 ( arg0 ) ; if ( len != ( ( Number ) arg0 ) . doubleValue ( ) ) { String msg = ScriptRuntime . getMessage0 ( "msg.arraylength.bad" ) ; throw ScriptRuntime . constructError ( "RangeError" , msg ) ; } return new NativeArray ( len ) ; }
See ECMA 15 . 4 . 1 2