# ArrayNew

Return new array

## Method Signature

```
ArrayNew()
```

### Arguments

This function does not accept any arguments

## Examples

### Create the One dimensional array

Uses the arrayNew function to create the new array

[Run Example](https://try.boxlang.io/?code=eJx1jkELgkAUhM%2Furxg8KQhieRMDOwR1qIP9gYVesbSt8txlsei%2Ft4rRqcvM4c18bwz5hlmOqCEnP5JPUCCtxNA9aDmJPMeZpRl6pYnhO75L7py54NoxtvsdmKxjAzv2JJIkoG5FNulq1vWsJVLUG7xENH9qyf4PViL6ItlRJd5pArNMzRAqZYa40RpqgCet46niWVk6Odu7QD60p2NLrKRWT%2FqVw4aQ%2FACv%2B0zp)

```java
newArray = arrayNew( 1 );
someArray =
// Transpiler workaround for BIF return type
(( arg1, arg2, arg3, arg4 ) => {
	arraySet( arg1, arg2, arg3, arg4 );
	return true;
})( newArray, 1, 4, "All is well" );
writeOutput( JSONSerialize( newArray ) );

```

Result: \["All is well", "All is well", "All is well", "All is well"]

### Create the Two dimensional array

Uses the arrayNew function to create the new array

[Run Example](https://try.boxlang.io/?code=eJzLSy13LCpKrFSwVUgE0X6p5RoKRgqa1lx5UJloBUOFWDABVKPklllUXKJQlphTmqpElhoj%2FGqMkMwJTk3Oz0vBpcgIq6LyosySVP%2FSkoLSEg0Fr2B%2Fv%2BDUoszEnMyqVA0FmAEKmiD%2FAQDN5k2Q)

```java
newArray = arrayNew( 2 );
newArray[ 1 ][ 1 ] = "First value";
newArray[ 1 ][ 1 ] = "First value";
newArray[ 1 ][ 2 ] = "First value";
newArray[ 2 ][ 1 ] = "Second value";
newArray[ 2 ][ 2 ] = "Second value";
writeOutput( JSONSerialize( newArray ) );

```

Result: \[\["First value", "First value"],\["Second value", "Second value"]]

### Create unsynchronized array

Uses the arrayNew function to create the new unsynchronized array

[Run Example](https://try.boxlang.io/?code=eJzLSy13LCpKrFSwVUgE0X6p5RoKhjoKaYk5xakKmtZceVAFeokFBal5KRoKSvl5qUogmfKizJJU%2F9KSgtISDQWvYH%2B%2F4NSizMSczKpUDQWYLgVNkEoAs4AhBw%3D%3D)

```java
newArray = arrayNew( 1, false );
newArray.append( "one" );
writeOutput( JSONSerialize( newArray ) );

```

Result: \["one"]

### Create an array using implicit notation

Instead of using arrayNew you can also create an array using square brackets.

[Run Example](https://try.boxlang.io/?code=eJzLSy13LCpKrFSwVYhW4OJUys9LVdIB0iXl%2BUpcsdZc5UWZJan%2BpSUFpSUaCl7B%2Fn7BqUWZiTmZVakaCnkwvZoKmtZcAEruFrI%3D)

```java
newArray = [ 
	"one",
	"two"
];
writeOutput( JSONSerialize( newArray ) );

```

Result: \["one", "two"]

### Create an array with data type

When using data types on array creation, items are converted if possible, otherwise an error is thrown.

```java
typedArray = arrayNew[ "boolean" ]( 1 );
typedArray[ 1 ] = true;
typedArray[ 2 ] = "true";
typedArray[ 3 ] = 1;
typedArray[ 4 ] = "1";
typedArray[ 5 ] = "yes";
typelessArray = arrayNew( 1 );
typelessArray[ 1 ] = true;
typelessArray[ 2 ] = "true";
typelessArray[ 3 ] = 1;
typelessArray[ 4 ] = "1";
typelessArray[ 5 ] = "yes";
writeOutput( JSONSerialize( [
	typedArray,
	typelessArray
] ) );

```

Result: \[\[true,true,true,true,null,true],\[true,"true",1,"1",null,"yes"]]

### Additional Examples

[Run Example](https://try.boxlang.io/?code=eJxLVLBVSCwqSqz0Sy3XUDBU0LTm0tdX8MwtyMlMziyBSCnk5ZcklmTm53El6iUWFKTmpWgoRMdClZZnlmQolCXmlKYWI0tzcSolKukAySQQaQzEJkAcHQskqrk4OZ39fQN8XCMUrBRKikpTuThrgeKFpalFEGcoZabopCSWpCopaHKB7UkpzS3QUEgEMQGlfTAO)

```java
a = arrayNew( 1 );
// Implicit array notation
a.append( [] );
// with values
a.append( [
	"a",
	"b",
	3,
	4,
	[],
	{
		COMPLEX : true
	},
	queryNew( "id,date" )
] );
dump( a );

```

## Related

* [ArrayAppend](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/array/arrayappend)
* [ArrayAvg](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/array/arrayavg)
* [ArrayChunk](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/array/arraychunk)
* [ArrayClear](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/array/arrayclear)
* [ArrayContains](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/array/arraycontains)
* [ArrayContainsNoCase](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/array/arraycontainsnocase)
* [ArrayDelete](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/array/arraydelete)
* [ArrayDeleteAt](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/array/arraydeleteat)
* [ArrayDeleteNoCase](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/array/arraydeletenocase)
* [ArrayEach](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/array/arrayeach)
* [ArrayEvery](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/array/arrayevery)
* [ArrayFilter](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/array/arrayfilter)
* [ArrayFind](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/array/arrayfind)
* [ArrayFindAll](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/array/arrayfindall)
* [ArrayFindAllNoCase](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/array/arrayfindallnocase)
* [ArrayFindFirst](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/array/arrayfindfirst)
* [ArrayFindNoCase](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/array/arrayfindnocase)
* [ArrayFirst](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/array/arrayfirst)
* [ArrayFlatMap](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/array/arrayflatmap)
* [ArrayFlatten](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/array/arrayflatten)
* [ArrayGetMetadata](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/array/arraygetmetadata)
* [ArrayGroupBy](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/array/arraygroupby)
* [ArrayIndexExists](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/array/arrayindexexists)
* [ArrayInsertAt](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/array/arrayinsertat)
* [ArrayIsDefined](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/array/arrayisdefined)
* [ArrayLast](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/array/arraylast)
* [ArrayMap](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/array/arraymap)
* [ArrayMax](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/array/arraymax)
* [ArrayMedian](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/array/arraymedian)
* [ArrayMerge](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/array/arraymerge)
* [ArrayMid](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/array/arraymid)
* [ArrayMin](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/array/arraymin)
* [ArrayNone](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/array/arraynone)
* [ArrayPop](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/array/arraypop)
* [ArrayPrepend](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/array/arrayprepend)
* [ArrayPush](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/array/arraypush)
* [ArrayRange](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/array/arrayrange)
* [ArrayReduce](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/array/arrayreduce)
* [ArrayReduceRight](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/array/arrayreduceright)
* [ArrayReject](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/array/arrayreject)
* [ArrayResize](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/array/arrayresize)
* [ArrayReverse](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/array/arrayreverse)
* [ArraySet](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/array/arrayset)
* [ArrayShift](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/array/arrayshift)
* [ArraySlice](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/array/arrayslice)
* [ArraySome](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/array/arraysome)
* [ArraySort](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/array/arraysort)
* [ArraySplice](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/array/arraysplice)
* [ArraySum](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/array/arraysum)
* [ArraySwap](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/array/arrayswap)
* [ArrayToList](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/array/arraytolist)
* [ArrayToStruct](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/array/arraytostruct)
* [ArrayTranspose](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/array/arraytranspose)
* [ArrayUnique](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/array/arrayunique)
* [ArrayUnshift](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/array/arrayunshift)
* [ArrayZip](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/array/arrayzip)
