#1 India's Top IT Training Institute
×

About Uncodemy

Know more about who we are and what we stand for.

About Us

About Us

Discover our mission to equip individuals with essential IT skills and industry expertise.

Read More →
UnCodeMy Gallery

UnCodeMy Gallery

Explore highlights from our IT training sessions and success stories.

Read More →
Mentors

Mentors

Meet the industry experts who train and guide you through your course.

Read More →
Free Resources

Free Resources

Free tutorials, interview questions, tools and calculators to help you learn.

Explore →
×

Free Resources

Learn, practice and plan your career — bilkul free.

Tutorials

Tutorials

Step-by-step written tutorials to learn any technology at your own pace.

Read More →
Free Counselling

Free Counselling

Book a free video counselling session and pick the right course for you.

Read More →
Online Compiler

Online Compiler

Write, run and test your code online — no setup required.

Read More →
JavaScript Fundamentals

Limitations

JavaScript is powerful, but it runs inside rules that limit what it can do, especially in the browser. Those limits exist mostly for safety: a web page from any site should not be able to read your files or take over your computer. Knowing them helps you choose the right tool and avoid designing features that cannot work, such as trusting a check that a user can simply switch off.

Limits that come from the browser sandbox

  • No free access to files. Browser JavaScript cannot read or write arbitrary files on the user's disk. It can only read files the user picks, for example through an <input type="file">, or use storage areas the browser provides, such as localStorage and IndexedDB.
  • No direct hardware or system control. It cannot launch programs, change system settings or access devices freely. Features like the camera, microphone or location need permission prompts the user can refuse.
  • Same-origin policy. A script on one site cannot read responses from another site's server unless that server allows it with CORS headers. It also cannot read the contents of pages from other origins opened in frames or tabs.

Limits of running on the user's machine

Because code is sent to the browser and run there, some limits follow naturally:

  • Your code is visible. Anyone can open developer tools and read it. Minification makes it harder to read but does not hide it. Never put passwords, private API keys or secret business logic in front-end JavaScript.
  • Users can change it. They can edit variables, skip checks or send requests directly. Client-side validation and price calculations must be repeated on the server.
  • It can be turned off. A small number of users disable JavaScript, and search engine crawlers or slow devices may not run all of it. Important content should not depend on scripts alone.
  • Performance depends on the device. A heavy script that runs smoothly on a fast laptop can freeze an older phone.

Limits in the language itself

LimitationWhat it meansCommon workaround
Single main threadLong-running code blocks clicks, scrolling and rendering.Split work into smaller chunks, or use Web Workers.
Floating-point numbers0.1 + 0.2 gives 0.30000000000000004.Round for display; store money as whole paise or cents.
Safe integer limitIntegers above Number.MAX_SAFE_INTEGER lose precision.Use BigInt for very large whole numbers.
Dynamic typingType mistakes show up only when the code runs.Linters, tests, or TypeScript.

Seeing the main-thread limit in practice

document.querySelector('#slow').addEventListener('click', () => {
  const end = Date.now() + 3000;
  while (Date.now() < end) {
    // busy loop: the page cannot respond for 3 seconds
  }
  console.log('Finished');
});

console.log(0.1 + 0.2 === 0.3);                    // false
console.log(Math.abs(0.1 + 0.2 - 0.3) < Number.EPSILON); // true
console.log(9007199254740993);                    // prints 9007199254740992
console.log(9007199254740993n);                   // BigInt keeps it exact

Click the button and try selecting text or scrolling: nothing happens until the loop finishes. That is the single thread at work.

The misunderstanding to avoid

The most damaging mistake is treating browser JavaScript as a security boundary. Hiding an admin button with script, disabling a form field, or checking a coupon code only in the browser stops honest users but not anyone with developer tools. Treat the browser as untrusted and enforce every rule that matters on the server.

It is also worth separating browser limits from language limits. Node.js runs the same language outside the browser and can read files, open network ports and run system commands. The sandbox rules above apply to web pages, not to JavaScript everywhere.

Working within the limits

Keep secrets and final checks on the server, break long tasks into small pieces, handle decimals carefully, and make key content available without scripts. The next lesson looks at the <script> element, which controls how and when the browser loads your JavaScript.

Ready to master real-world web development?

Learn HTML, CSS3, Bootstrap and JavaScript hands-on with mentor-led sessions.

Explore Course