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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T05:20:25+00:00 2026-05-27T05:20:25+00:00

I have a function that I am calling the following way but it returns

  • 0

I have a function that I am calling the following way but it returns someVariable.clean is not a function

Here is the code:

var someVariable = function() {
        this.clean = function(obj) {
            alert(obj);
        }
    }

    someVariable.clean('test'); //call

Any idea why it is happening, what am I doing wrong?

  • 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-27T05:20:25+00:00Added an answer on May 27, 2026 at 5:20 am

    If your’re not in ES5 strict mode, you’ll add the function .clean() to the global object.

    So, just calling clean('test'); would indeed work here. If you want it like you described, you need to return the function an object.

    var someVariable = function() {
        return {
            clean: function(obj) {
                alert(obj);
            }
        };
    };
    

    If you are in ES5 strict mode, this code would throw an error, since this would be bound to null. What the this context variable is referenced to, always depends on how the function is invoked. In your case, as described, this is either window or null.

    It would also work, if you’d invoke your function with the new keyboard:

    new someVariable().clean('test');
    

    That is because, new makes the function a constructor function and this is always bound to a newly created object within the function.

    • 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 is recursively calling itself, and i want to detect
I have the view function in django that written like a dispatcher calling other
In my Java code I have function that gets file from the client in
I have a function that gives me the following warning: [DCC Warning] filename.pas(6939): W1035
I have a function that looks like this class NSNode { function insertAfter(NSNode $node)
I have a function calling another function to get data. That data might be
Say I have the following jQuery plugin: $.fn.myPlugin = function () { //plugin code
I have a quite inconvenient problem. Say that I have the following functions function
I have the following function that is pulling data from a database. The ajax
I have the following javascript code, which loads without error, however the update function

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.