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

  • Home
  • SEARCH
  • 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 6037129
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T06:01:42+00:00 2026-05-23T06:01:42+00:00

If I have a object, with a function that captures every form on the

  • 0

If I have a object, with a function that captures every form on the page as an array:

var object = 
{
 var forms = document.getElementsByTagName("form");

And I add an event listener to it (W3C DOM 2 Event Model, I don’t care about IE for this example):

addEventListener = function(target, type, listener)
{
 target.addEventListener(type, listener, false);
};

And I call (normally a loop, but lets just take one example):

addEventListener(forms[i], "change", changeListener);

And changeListener is equal to:

changeListener: function(event)
{
 updateDependents(this);
}

And updateDependents equals:

updateDependents: function(form)
   {
    ...
   }
};

can someone explain to me the progression of arguments (i.e. what “this” and “event” are equal to)?

To me, it looks like:

For the form in question (forms[i]), an event listener is being added based upon a “change” event, and the action to be taken is “changeListener”.

changeListener takes an argument of (event), so it must be referencing potential event that forms[i] has(?). [not sure about this]

It then calls “updateDependents(this)”… what is the “this” here? Is it the form that is identified in the “target” argument of the “addEventListener” method, or is it the event argument that exists within the “changeListener(event)” method? [can someone please explain why it would be one over the other?]

Note: I’m obviously confused, so I apologize for any stupidity. Also, this is an excerpt from “Simply Javascript” by Sitepoint.

Cheers,

Sapiensgladio

  • 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-23T06:01:43+00:00Added an answer on May 23, 2026 at 6:01 am

    In JS this only gets a value in a few ways:

    1. When calling someObj.method(), then this === someObj

    2. Calling method.call(someObj, ...), then this === someObj, and likewise for method.apply(someObj, args)

    3. In Javascript 1.8.5 / ES5, by using Function.prototype.bind()

    If a method is invoked simply as method() then this === window (or whatever the global object is if you’re not in a browser).

    DOM2’s addEventListener() uses #2 above and sets this to be the element from which the event was fired.

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

Sidebar

Related Questions

I have a function that loads a user object from a web service asynchronously.
If I have a function that returns an object, but this return value is
I have a function that, among other things, takes in an object and a
I have a label function like : private function formatDate (item:Object, column:DataGridColumn):String { var
I'm using jQuery and I have a function that serves as an event callback,
I have a function that takes an object of a certain type, and a
If I have the following function that iterates through a json response object (val2):
I have a class with an Attach function that accepts a function object and
Let's asume that I have an object: var obj = {A:a, B:b, x:y, a:b}
i have this code in javascript: var object = { get: function(id){ sel =

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.