tessel / t1-runtime

[UNMAINTAINED] Tessel 1 JavaScript runtime.
Other
117 stars 33 forks source link

Array slice not behaving properly #695

Closed adkron closed 9 years ago

adkron commented 9 years ago

Slice on the tessel does not match slice in node. I was trying to use it to shift around some bits before writing to the ht16k33 backpack. https://github.com/BinaryNoggin/backpack-ht16k33

node repl

> var row = [0,0,1,1,1,1,0,0] 
undefined
> row
[ 0,
  0,
  1,
  1,
  1,
  1,
  0,
  0 ]
> row.slice(-1)
[ 0 ]
>  row.slice(0,-1)
[ 0,
  0,
  1,
  1,
  1,
  1,
  0 ]
> row.slice(-1).concat(row.slice(0,-1))
[ 0,
  0,
  0,
  1,
  1,
  1,
  1,
  0 ]
> 

tessel repl

> var row = [0,0,1,1,1,1,0,0]
[ 0,
  0,
  1,
  1,
  1,
  1,
  0,
  0 ]
> row.slice(-1)
[ null,
  0,
  0,
  1,
  1,
  1,
  1,
  0,
  0 ]
> row.slice(0,-1)
[]
> row.slice(-1).concat(row.slice(0,-1))
[ null,
  0,
  0,
  1,
  1,
  1,
  1,
  0,
  0 ]