Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4625410
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T03:16:06+00:00 2026-05-22T03:16:06+00:00

A few people I work with include on their sites some javascript I wrote

  • 0

A few people I work with include on their sites some javascript I wrote and host. But some of those sites use prototype.js or some other framework and its causing some big problems.

For example:

var test = {"one":[{"a":"b"}]};
for (var i in test.one) { console.log(i); }

The expected result of this would be “0” in the console (i being the key to that array)

But if I go to a site like prototypejs.org and run the same code in firebug’s console, I get a list of all the prototype junk (each, eachSlice, etc..)

Try running it in your console here on stackoverflow, it returns “0” as expected.

How do I prevent this? Any good workarounds?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T03:16:06+00:00Added an answer on May 22, 2026 at 3:16 am

    Either test that each property you enumerate is NOT in the prototype

    for (var i in test.one) { 
       if (test.one.hasOwnProperty(i)) {
          console.log(i); 
       }
    }
    

    or don’t enumerate arrays.

    for (var i = 0, ii = test.one.length; i < ii; i++) {
         console.log(i);
    }
    

    Any code that extends Object.prototype is not your problem. You should not have to guard against that.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

At work we have 4 people working together on a few different projects. For
I've found a few samples online but I'd like to get feedback from people
What is Lazy Loading? [Edit after reading a few answers] Why do people use
Hey guys, I've seen a few people bring it up but haven't found a
A few people have touched on it, but no-one appears to have outright asked
I have a special url which I would want only few people to have
I've read a few posts where people have stated (not suggested, not discussed, not
I am having a few issues when people are trying to access a MySQL
As probably many people around here I read a few webcomics. Drowtales is my
Based on a few posts I've read concerning version control, it seems people think

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.