I am doing server-side javascript and i need to have a typed array of byte of a certain size.
I tried :
var buf = [1024]; (guives me Cannot convert org.mozilla.javascript.NativeArray@1e565bd to byte[] error)
var buf = byte[1024]; (wrong synthax)
What is the synthax?
This depends on which server-side JavaScript package you use. Different packages implement different flavors of JavaScript and different versions of ECMAScript.
In NodeJS v0.6.x you have access to typed arrays. Creating one of these arrays is fairly trivial.
There are other typed arrays available, handling 16 bit and 32 bit integers.
When using typed arrays, there are a few things to keep in mind. Typed arrays do not inherit the standard array prototype, and these arrays have an immutable length.