Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

114
Views
performance of Typed arrays vs Non typed arrays in Javascript

Learning about typed arrays, I read typed arrays normally should be more efficient/performant than non-typed ones.

I run this simple test (replace a for b to run each test):

const a = [1, 2, 3, 4]
const b = new Uint8Array([1, 2, 3, 4])

const compare1 = (arr) => {
  for (let i = 0; i < 4; i++) arr[i]
}

let run = 0

const init1 = performance.now()

while (run < 10e7) {
  compare1(a)
  run++
}

const finish1 = performance.now()
console.log("for a ", finish1 - init1)

const compare2 = (arr) => {
  for (let i = 0; i < 4; i++) arr[i]
}

run = 0
const init2 = performance.now()

while (run < 10e7) {
  compare2(b)
  run++
}

const finish2 = performance.now()

console.log("for b ", finish2 - init2)

array contains mixed string and number types.

But maybe I am not getting some idea here...

Should those be expected to differ more? Example?


Edit: Added 2 different compareX functions.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!