ECMAScript data types

This article or section is a stub. It does not yet contain enough information to be considered a real article. In other words, it is a short or insufficient piece of information and requires additions.

Draft

For now, this is a simple outline to keep track of the concepts that are assumed to have been described.

## Contents

* 1 Introduction
* 2 Primitive Data Types
* 2.1 Numbers
* 2.2 Strings
* 2.3 Boolean
* 2.4 Null
* 2.5 void
* 3 Complex data types in ActionScript core classes
* 3.1 Arrays
* 3.2 Objects
* 4 Links
* 4.1 Manuals and specifications
* 4.2 JavaScript Tutorials

## Introduction[edit | edit source]

For now we describe the data types you need to write basic programs.

## Primitive Data Types[edit | edit source]

Boolean, int, Null, Number, String, uint, and void.

### Numbers[edit | edit source]

Number. Data type representing any sort of number. int. Integer. Data type representing a number with no decimal part. uint. Unsigned integer. Data type representing a non negative integer

### Strings[edit | edit source]

A variable of string data types represent a sequence of characters.

### Boolean[edit | edit source]

Variables defined as of boolean type can hold only two values: true or false. No other values are valid. When a boolean variable is declared without being given an initial value, its value is false.

### Null[edit | edit source]

The Null data type contains only one value, null

### void[edit | edit source]

The void data type contains only one value, undefined.

## Complex data types in ActionScript core classes[edit | edit source]

The full list of ActionScript 3 datatypes include: Object, Array, Date, Error, Function, RegExp, XML, and XMLList.

### Arrays[edit | edit source]

To create an array and to add some values, you can use something like:

var mylist = Array ();
mylist[]=1;
mylist[]=2; mylist[]=3;

var mylist = [1,2,3];

Default numbering of elements starts at zero.

mylist[0]; // will return 1, i.e. the first element.

You can define the length of an array:

var mylist = new Array(12);

But it then can be increased later, e.g. this is ok:

mylist(14) = "bla";

There are several sorts of arrays:

* normal arrays (as seen above)

var xx = [1,2,3];

But then we also can have:

* typed arrays (ECMAScript 4 / JavaScript 2 - not tested !)

var xx = [ int] (12); // an array of 13 integer elements
var xx = [1,2,3] : [int]; // an array filled with 2 int. elements
var xx = new [int] (1,2,3); // same

* associative arrays (records)

var hash = { x:10, y:"foo" }

This will return 10:

alert(hash ['x']);

* typed associative arrays (ECMAScript 4 / JavaScript 2 - not tested !)

var hash = new { x:int, y:string }( 3, "foo" )
var hash = { x:10, y:"foo" } : { x:int, y:string }

### Objects[edit | edit source]

Objects are an unordered collection of properties each of which contains a primitive value, object, or function. A function stored in a property of an object is called a method.

Internally speaking, objects are a kind of associative arrays or whatever they are called (e.g. records or hash structures). In fact, arrays are a special case of objects, i.e. an array is defined by the global JS object Array.prototype

Anyhow, the following should be internally the same or mostly (?) the same.

var take1 = {'prop1':0, 'prop2':1, 'prop2':2};

var take2 = new Object();
take2['prop1'] = 0;
take2['prop2'] = 1;
take2['prop3'] = 2;

var take3 = new Object();
take3.prop1 = 0;
take3.prop2 = 1;
take3.prop3 = 2;

## Links[edit | edit source]

### Manuals and specifications[edit | edit source]

Flash 9/ActionScript 3

* Data type descriptions @ Adobe livedocs

JavaScript 1.5

* Core JavaScript 1.5 Reference:Global Objects:Array

ECMAScript

* ECMAScript Language Specification (this is something normal people like you and me have difficulty understanding)

### JavaScript Tutorials[edit | edit source]

* Objects as associative arrays