How to Find the Largest Number in an Array in JavaScript?

Do you want to know what the largest number in JavaScript is and how to find the largest number in an array?

In this article, you’ll discover the largest number and also learn how to find the largest number in an array using JavaScript.

Sounds great, right? So what are you waiting for? Let’s get started!

What is the largest number in JavaScript?

There are two types of numbers In JavaScript, the Number and BigInt.

The Number type is the most commonly used. It’s a 64-bit floating point number, following the IEEE 754 standard.

The largest number in JavaScript that can be represented exactly (meaning without any loss of precision) is known as Number.MAX_SAFE_INTEGER, which equals 2^53-1, or +/- 9,007,199,254,740,991.

However, the absolute largest number that can be represented by the Number type is Number.MAX_VALUE, which is approximately 1.7976931348623157e+308. If you try to use a number larger than this, JavaScript will represent it as Infinity.

Now, if you need to work with really large numbers, JavaScript has another type called BigInt. This type was introduced in ES2020 and can represent integers of any length without losing precision. For instance, you could use BigInt to accurately represent a number like 1 followed by 10,000 zeros!

Solutions on how to find the largest number in an array in JavaScript

The following are the several ways to find the largest number in an array in JavaScript:

Solution 1: Use the Math.max() function with the spread operator (…)

To find the largest number in an array, you can use the Math.max() function with the spread operator. The Math.max() returns the largest of zero or more numbers.

Meanwhile, the spread operator (…) is used to expand the elements of our array into arguments of the Math.max() function.

Here’s an example:

let SampleArray = [10, 20, 30, 40, 50];
let LargestArray = Math.max(...SampleArray); ✅
console.log(LargestArray); 

Output:

50

Solution 2: Use the Math.max() function with the apply() method

You can also use Math.max() but in conjunction with the apply() method.

The apply() method calls a function with a given value and arguments provided as an array (or an array-like object).

Here’s an example:

let SampleArray = [11, 22, 33, 44, 55];
let LargestArray = Math.max.apply(null, SampleArray); 
console.log(LargestArray);

In this case, we’re passing null as this value (since Math.max() doesn’t use this), and our array as the arguments.

Output:

55

Solution 3: Use the reduce() method

You can also use the reduce() method. This method applies a function against an accumulator (in this case, a) and each element in the array (from left to right) to reduce it to a single output value.

The function we’re using is again Math.max(), so we’re essentially comparing each element in the array to find the maximum value.

Here’s an example:

let SampleArray = [1000, 200, 300, 400, 500];
let LargestArray = SampleArray.reduce(function(x, y) { 
return Math.max(x, y);
});
console.log(LargestArray);

Output:

1000

Conclusion

In conclusion, we have explored the concept of the largest number in JavaScript and how to find the largest number in an array.

We learned that JavaScript has two types of numbers: Number and BigInt. The Number type can represent numbers up to approximately 1.7976931348623157e+308, and for exact integers, it can go up to 2^53-1 or +/- 9,007,199,254,740,991.

For larger numbers, JavaScript provides the BigInt type.

We also discussed three different methods to find the largest number in an array in JavaScript: using the Math.max() function with the spread operator (…), using the Math.max() function with the apply() method, and using the reduce() method.

We hope this article has provided you with enough information to understand how to find the largest number in JavaScript array.

If you want to explore more JavaScript topics, check out the following articles:

Thank you for reading Itsourcecoders 😊.

Quick step-by-step summary (click to expand)
  1. What is the largest number in JavaScript. Read the ‘What is the largest number in JavaScript?’ section for the details and code.
  2. Solutions on how to find the largest number in an array in JavaScript. Read the ‘Solutions on how to find the largest number in an array in JavaScript’ section for the details and code.
  3. Conclusion. Read the ‘Conclusion’ section for the details and code.

Frequently Asked Questions

Is JavaScript still worth learning in 2026?
Yes. JavaScript runs on 98% of websites for the front-end, dominates the back-end via Node.js, powers mobile apps through React Native, builds desktop tools through Electron, and is the scripting layer for most AI tooling (LangChain.js, OpenAI SDK, Vercel AI). Whether you target web, mobile, AI, or full-stack capstones, JavaScript is the broadest single language you can learn.
What is the difference between var, let, and const?
var is function-scoped, hoisted to the top of its scope, and can be redeclared, which leads to bugs in modern code. let is block-scoped (only visible inside the nearest {}) and can be reassigned. const is block-scoped and cannot be reassigned, although object contents can still mutate. Default to const for everything, switch to let only when you actually need to reassign, and avoid var in any code written after 2017.
Which JavaScript version should I target in 2026?
Target ES2020 (ES11) as the safe baseline because every modern browser and Node.js 14+ supports it fully. ES2022 adds useful features like top-level await, private class fields with the # prefix, and the .at() array method. If you are writing for older browsers (IE11 or older Android WebViews), transpile down with Babel or use a build tool like Vite, esbuild, or webpack.
What is the best free editor for JavaScript?
Visual Studio Code is the industry standard, free, with built-in IntelliSense, debugger, terminal, Git, and a huge extension marketplace (ESLint, Prettier, GitHub Copilot, Tailwind). Install the JavaScript and TypeScript Nightly extension for the latest language features. JetBrains WebStorm is more powerful and free for students with a verified .edu email. For quick scratchpad work, the Chrome DevTools Sources panel includes a workspace and breakpoint debugger.
How do I run JavaScript locally vs in the browser?
In the browser: open DevTools with F12 (or right-click then Inspect), go to the Console tab, type or paste your code, press Enter. For HTML pages, add a script tag pointing to your .js file. Locally with Node.js: download Node from nodejs.org (LTS version), then run node script.js in your terminal from the file folder. Use the same Node setup for backend capstones, API integrations, and scripts that do not need a browser.
What can I build with JavaScript for my BSIT capstone?
Common BSIT capstones in JavaScript: full-stack web apps using React or Vue on the front-end with Node.js and Express on the back-end (MongoDB or MySQL for the database), real-time chat or notification systems using Socket.io, single-page dashboards with Chart.js or D3.js, cross-platform mobile apps with React Native, AI-powered chatbots using OpenAI SDK and LangChain.js, and Chrome extensions for productivity tools. Add Tailwind CSS for the UI and Vercel or Netlify for free deployment.

Caren Bautista


Technical Writer at PIES IT Solution

Responsible for crafting clear, well-structured, and beginner-friendly content across the platform. Handles the writing, proofreading, and editorial review of tutorials, guides, and documentation to ensure every article is accurate, readable, and easy to follow.

Expertise: Technical Writing · Content Creation · Documentation · Editorial Writing · JavaScript · TypeScript · Python · Python Errors · HTTP Errors · MS Excel
 · View all posts by Caren Bautista →

Leave a Comment