# Typed Arrays: Y U No offset at values other than multiples of element size?

**URL:** https://forum.kirupa.com/t/typed-arrays-y-u-no-offset-at-values-other-than-multiples-of-element-size/331210
**Category:** web dev
**Created:** [June 13, 2013, 3:59pm UTC](https://forum.kirupa.com/t/typed-arrays-y-u-no-offset-at-values-other-than-multiples-of-element-size/331210 "2013-06-13T15:59:17Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![senocular](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/senocular/32/7217_2.png) [@senocular](https://forum.kirupa.com/u/senocular)
#### Post date: [June 13, 2013, 3:59pm UTC](https://forum.kirupa.com/t/typed-arrays-y-u-no-offset-at-values-other-than-multiples-of-element-size/331210/1 "2013-06-13T15:59:17Z")

</div>

[http://www.khronos.org/registry/typedarray/specs/latest/#TYPEDARRAYS](http://www.khronos.org/registry/typedarray/specs/latest/#TYPEDARRAYS)

```auto

TypedArray(ArrayBuffer buffer, optional unsigned long byteOffset, optional unsigned long length)

```

> 

The given byteOffset must be a multiple of the element size of the specific type, otherwise an exception is raised.

But Why?

Like, I have this color, right? And it’s prefixed with, let’s say, a 1-byte “header” value. And I want a 32 bit uint view into the color, but I can’t get it :fight:

```auto

var data = new Uint8Array([8, 255,255,255,255]);
var buffer = data.buffer;

// gimme mah colah!
var color = new Uint32Array(buffer, 1,1); // first 1 to offset into buffer 1 byte skipping `8`

```

> 

“Size is too large (or is negative).” (gc)  
or  
“Invalid offset/length when creating typed array” (ie)  
or  
“Error: invalid arguments” (ff)

So I’m just expected to have to go in and piece my color (or possible collection of many consecutive 32 bit colors) through the individual bytes? (And [IE don’t do no slice](http://connect.microsoft.com/IE/feedback/details/781472/arraybuffer-prototype-slice-is-not-implemented), so don’t even try…)

Bah! Web technologies … (holds back) … are _difficult_.
