All Downloads are FREE. Search and download functionalities are using the official Maven repository.

rhino1.7.7.testsrc.doctests.array.sparse.doctest Maven / Gradle / Ivy

Go to download

Rhino is an open-source implementation of JavaScript written entirely in Java. It is typically embedded into Java applications to provide scripting to end users.

There is a newer version: 1.7.15
Show newest version
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.

// test various array methods with sparse arrays
js> var x = []

js> x.length = 101
101
js> x[100] = 1
1
js> x.length
101
js> 0 in x
false
js> x.shift()
js> x.length
100
js> 0 in x
false
js> x
,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,1
js> x.reverse()
1,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
js> x.length
100
js> 10 in x
false
js> x.reverse()
,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,1
js> x.length
100
js> 10 in x
false
js> x.unshift(2)
101
js> x
2,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,1
js> 10 in x
false
js> var r = x.splice(50, 5, 3, 4, 5)
js> r
,,,,
js> r.length
5
js> 3 in r
false
js> x.length
99
js> x
2,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,3,4,5,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,1
js> x[50]
3
js> 10 in x
false
js> var s = x.slice(60, 70);
js> s
,,,,,,,,,
js> s.length
10
js> 5 in s
false
js> var y = []
js> y.length = 100
100
js> var z = y.concat(x)
js> z.length
199
js> 30 in z
false
js> 130 in z
false





© 2015 - 2024 Weber Informatics LLC | Privacy Policy