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

86
Views
How to mock one element in an Array in javascript test -- Solved

I'm writing a javascript test, and am trying to mock one element in an array, I'm not sure this is the correct way to say it, but this is what I'm trying to do.

const arr = [1, 2, 3];
arr[0].mockReturnValue(4); 
//so in the end, I want the array to be [4,2,3] when I pass it into another function. 

Is there anyway I can do this?

Solved-- arr[0] = 4;

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!