I am working with a system that has the following structure:
interface Data {
x: number;
y: number;
n: string;
}
const array = Array<Data>(100);
I have heard that in Chrome, the V8 engine may allocate objects as C arrays if the array contains only the same type of data. Is there a way to check if my 'array' object will function as a C array or dictionary? In other words, how can I determine if the memory is contiguous?
If such a check is not feasible, I know that I could utilize a SoA model using TypedArrays like so:
interface Data {
x: Float64Array;
y: Float64Array;
n: ????;
}
const dataArray = {
x: new Float64Array(100),
y: new Float64Array(100),
n: ????????
} as Data
However, I am unsure about how to store Strings in an array structured in this manner.