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 3273302
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T18:55:03+00:00 2026-05-17T18:55:03+00:00

I found this piece of code which seems pretty cool. I see return new

  • 0

I found this piece of code which seems pretty cool. I see return new Set(array); written so i know set is a class. But what does Set[proto] mean and what does [push] mean and .pop and why is
one a dot while the other is in square brace.

Also arguments[length] looks pretty cool. I imagine its an implicit parameter in each func? i am not sure how length works in this case. This looks really cool and i am very much a newbie at JS.

// Set
var Set = function (items) {
    this.items = [];
    this[length] = 0;
    this.type = "set";
    if (items) {
        for (var i = 0, ii = items[length]; i < ii; i++) {
            if (items[i] && (items[i].constructor == Element || items[i].constructor == Set)) {
                this[this.items[length]] = this.items[this.items[length]] = items[i];
                this[length]++;
            }
        }
    }
};
Set[proto][push] = function () {
    var item,
        len;
    for (var i = 0, ii = arguments[length]; i < ii; i++) {
        item = arguments[i];
        if (item && (item.constructor == Element || item.constructor == Set)) {
            len = this.items[length];
            this[len] = this.items[len] = item;
            this[length]++;
        }
    }
    return this;
};
Set[proto].pop = function () {
    delete this[this[length]--];
    return this.items.pop();
};
  • 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-17T18:55:04+00:00Added an answer on May 17, 2026 at 6:55 pm

    In that code the proto variable is set to the string “prototype”, and the push variable is set to “push”. So, Set[proto] is the same as saying Set.prototype.

    So this:

    Set[proto][push] 
    

    is the same as:

    Set.prototype.push
    

    The code is actually creating a function on the Set’s prototype called push. A functions prototype is an object that all instances constructed from that function inherit.

    For more information about prototype property read this

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

Sidebar

Related Questions

I am learning about cronjob and I found this piece of code in one
I have a piece of jQuery code which - in theory - scrolls down
There is this famous quote that says Procedural code gets information then makes decisions.
Am just learning C and this is my first time on stackoverflow so am
Please forgive my attempts at necromancy, but I actually need to write some code
I don't know if it is legal on SOF to access such a specific
I am trying to extend the Microsoft Web Deployment tool and MSDeploy with a
I'm just starting to teach myself Objective C and have been fooling around with
I'm currently learning Magento and seem to have come across a problem that is

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.