function filledarray() {
	var value;
	var nargs;
	var dtype;
	var ctor;
	var arr;
	var len;
	var arg;

	nargs = arguments.length;
	nargs -= 1;
	if ( nargs >= 0 && isString( arguments[ nargs ] ) ) {
		dtype = arguments[ nargs ];
		nargs -= 1;
	} else {
		dtype = DEFAULT_DTYPE;
	}
	ctor = ctors( dtype );
	if ( ctor === null ) {
		throw new TypeError( format( 'invalid argument. Must provide a recognized data type. Value: `%s`.', dtype ) );
	}
	if ( dtype === 'generic' ) {
		if ( nargs <= 0 ) {
			return [];
		}
		value = arguments[ 0 ];
		arg = arguments[ 1 ];
		if ( nargs === 1 ) {
			if ( isNonNegativeInteger( arg ) ) {
				len = arg;
			} else if ( isCollection( arg ) ) {
				len = arg.length;
			}
			if ( len !== void 0 ) {
				return filled( value, len );
			}
			if ( isArrayBuffer( arg ) ) {
				throw new Error( 'invalid arguments. Creating a generic array from an ArrayBuffer is not supported.' );
			}
			if ( isObject( arg ) ) {
				if ( HAS_ITERATOR_SYMBOL === false ) {
					throw new TypeError( format( 'invalid argument. Environment lacks Symbol.iterator support. Must provide a length, typed array, or array-like object. Value: `%s`.', arg ) );
				}
				if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {
					throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) );
				}
				arg = arg[ ITERATOR_SYMBOL ]();
				if ( !isFunction( arg.next ) ) {
					throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) );
				}
				return filledIterator( arg, value );
			}
			throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) );
		} else if ( isArrayBuffer( arg ) ) {
			throw new Error( 'invalid arguments. Creating a generic array from an ArrayBuffer is not supported.' );
		}
		throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) );
	}
	if ( nargs <= 0 ) {
		return new ctor( 0 );
	}
	if ( nargs === 1 ) { // length || array-like || ArrayBuffer || iterable
		arg = arguments[ 1 ];
		if ( isCollection( arg ) ) {
			arr = new ctor( arg.length );
		} else if ( isArrayBuffer( arg ) ) {
			arr = new ctor( arg );
		} else if ( isNonNegativeInteger( arg ) ) {
			arr = new ctor( arg );
		} else if ( isObject( arg ) ) {
			if ( HAS_ITERATOR_SYMBOL === false ) {
				throw new TypeError( format( 'invalid argument. Environment lacks Symbol.iterator support. Must provide a length, typed array, or array-like object. Value: `%s`.', arg ) );
			}
			if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {
				throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) );
			}
			arg = arg[ ITERATOR_SYMBOL ]();
			if ( !isFunction( arg.next ) ) {
				throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) );
			}
			arr = new ctor( iterLength( arg ) );
		} else {
			throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) );
		}
	} else if ( nargs === 2 ) {
		arr = new ctor( arguments[1], arguments[2] ); // (ArrayBuffer, byteOffset)
	} else {
		arr = new ctor( arguments[1], arguments[2], arguments[3] ); // (ArrayBuffer, byteOffset, length)
	}
	if ( arr.length > 0 ) {
		value = arguments[ 0 ];
		if ( isComplexDataType( dtype ) ) {
			filledAccessors( arr, value );
		} else if ( isBooleanDataType( dtype ) ) {
			gfill( arr.length, ( value ) ? 1 : 0, reinterpretBool( arr, 0 ), 1 ); // eslint-disable-line max-len
		} else {
			gfill( arr.length, value, arr, 1 );
		}
	}
	return arr;
}
Creates a filled array.

@param {*} [value] - fill value
@param {(NonNegativeInteger|TypedArray|ArrayLikeObject|ArrayBuffer|Iterable)} [arg] - a length, typed array, array-like object, buffer, or iterable
@param {NonNegativeInteger} [byteOffset=0] - byte offset
@param {NonNegativeInteger} [length] - view length
@param {string} [dtype="float64"] - data type
@throws {TypeError} must provide a recognized data type
@throws {TypeError} must provide a length, typed array, array-like object, buffer, or iterable
@throws {Error} creating a generic array from an `ArrayBuffer` is not supported
@returns {(TypedArray|Array|ComplexArray)} array or typed array

@example
var arr = filledarray();
// returns <Float64Array>

@example
var arr = filledarray( 1.0, 2 );
// returns <Float64Array>[ 1.0, 1.0 ]

@example
var arr = filledarray( 1.0, 2, 'float32' );
// returns <Float32Array>[ 1.0, 1.0 ]

@example
var arr = filledarray( 1.0, 2, 'generic' );
// returns [ 1.0, 1.0 ]

@example
var arr = filledarray( 1.0, [ 0.5, 0.5 ] );
// returns <Float64Array>[ 1.0, 1.0 ]

@example
var arr = filledarray( 1, [ 5, -3 ], 'int32' );
// returns <Int32Array>[ 1, 1 ]

@example
var arr1 = filledarray( 2, [ 5, 3 ], 'int32' );
var arr2 = filledarray( 1.0, arr1 );
// returns <Float64Array>[ 1.0, 1.0 ]

@example
var arr1 = filledarray( 2, [ 5, 3 ], 'int32' );
var arr2 = filledarray( 1, arr1, 'uint32' );
// returns <Uint32Array>[ 1, 1 ]

@example
var ArrayBuffer = require( '@stdlib/array/buffer' );

var buf = new ArrayBuffer( 16 );
var arr = filledarray( 1.0, buf );
// returns <Float64Array>[ 1.0, 1.0 ]

@example
var ArrayBuffer = require( '@stdlib/array/buffer' );

var buf = new ArrayBuffer( 16 );
var arr = filledarray( 1.0, buf, 'float32' );
// returns <Float32Array>[ 1.0, 1.0, 1.0, 1.0 ]

@example
var ArrayBuffer = require( '@stdlib/array/buffer' );

var buf = new ArrayBuffer( 16 );
var arr = filledarray( 1.0, buf, 8 );
// returns <Float64Array>[ 1.0 ]

@example
var ArrayBuffer = require( '@stdlib/array/buffer' );

var buf = new ArrayBuffer( 16 );
var arr = filledarray( 1.0, buf, 8, 'float32' );
// returns <Float32Array>[ 1.0, 1.0 ]

@example
var ArrayBuffer = require( '@stdlib/array/buffer' );

var buf = new ArrayBuffer( 32 );
var arr = filledarray( 1.0, buf, 8, 2 );
// returns <Float64Array>[ 1.0, 1.0 ]

@example
var ArrayBuffer = require( '@stdlib/array/buffer' );

var buf = new ArrayBuffer( 32 );
var arr = filledarray( 1, buf, 8, 2, 'int32' );
// returns <Int32Array>[ 1, 1 ]