Debian Codegraph @

rhino/testsrc/doctests/480758.doctest

raw
1 // This Source Code Form is subject to the terms of the Mozilla Public
2 // License, v. 2.0. If a copy of the MPL was not distributed with this
3 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
4
5 js> function primBeget(proto) {
6 > if (proto === null) { fail("Cannot beget from null."); }
7 > if (proto === (void 0)) { fail("Cannot beget from undefined."); }
8 > function F() {}
9 > F.prototype = proto;
10 > var result = new F();
11 > return result;
12 > }
13 js> var x = [1].concat(primBeget(Array.prototype));
14 js> x
15 1,
16 js> x[1]
17
18 js> typeof x[1]
19 object
20 js> x[1] instanceof Array
21 true