JavaScript Programmer’s Reference Array.valueOf() (Method) Returns the contents (Database web hosting)

JavaScript Programmer’s Reference Array.valueOf() (Method) Returns the contents of the array converted to a native primitive value. Availability: JavaScript 1.1 JScript 3.0 Internet Explorer 4.0 Netscape 3.0 Property/method value type: String primitive JavaScript syntax: -myObject.valueOf() The primitive value of the receiving object is returned by this method. Because an array is an aggregation of many elements, a simple type conversion is not appropriate. The individual elements are converted to string values and are then concatenated together and returned as a single string primitive value. This applies even if an array comprises a collection of numeric values. See also: valueOf() Array simulation (Definition) A means of simulating arrays in JavaScript. With a constructor, you can simulate arrays by making them from objects and property components. This may be useful if you want to run an array-based script in a very old JavaScript implementation although these days that likelihood is diminishing rapidly. This was necessary in JavaScript version 1.0. Numbered index locations within an Object object could simulate Array objects. Named items simply allocate the next available numbered entry. Thankfully we don’t have to do this anymore. Warnings: . In Netscape 2.02 and MSIE 3.02 you can operate on existing arrays, but you cannot make a new one. . In Netscape 2.02 the array length value does not work properly. Example code: // Simulate an array with an Object object myArray = new Object(); myArray[0] = “One”; myArray[1] = “Two”; // Simulate an array with a constructor function SimArray(aSize) {

Leave a Reply