René Nyffenegger's collection of things on the web | |
René Nyffenegger on Oracle - Most wanted - Feedback
- Follow @renenyffenegger
|
Array [JavaScript snippet] | ||
function main() { var a = new Array() a[ 0] = 'zero' a[ 1] = 'one' a[ 2] = 'two' a[42] = 'forty-two' txt_out('typeof(a): ' + typeof(a)) // object if (40 in a) { txt_out('Array has element 40') } else { txt_out("Array doesn't have element 40") } if (1 in a) { txt_out('Array has element 1') } else { txt_out("Array doesn't have element 1") } }
See also other Javascript snippets
|