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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T19:12:28+00:00 2026-06-09T19:12:28+00:00

Second console.log() executed by WSFunctions[this.name](); will print undentified . I was wondering if I

  • 0

Second console.log() executed by WSFunctions[this.name](); will print undentified. I was wondering if I am able somehow to inherit DoThisAndThat in my Call() function. I didn’t want to pass params in the way WSFunctions[this.name](this.params) as while project grows there may be more than this.params to pass.

function WS(name, params) {
    this.name = name;
    this.params = params;
}

WS.prototype.Call = function() {
    if (typeof WSFunctions[this.name] !== "function") {
        return false;
    }

    console.log(this.params);
    WSFunctions[this.name]();

    return true;
}

var WSFunctions = {
    'ScreenRightGuest': function() {
        // .. whatever ..
        return true;        
    },
    'DoThisAndThat': function() {
        console.log(this.params);
        return true;
    }
}


new WS('DoThisAndThat', { login: '123', pass: 'abc' }).Call();

Thanks in advance
Mike

  • 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-06-09T19:12:30+00:00Added an answer on June 9, 2026 at 7:12 pm

    You can explicitly set what this should refer to in a function using .call [MDN] or .apply [MDN]

    WSFunctions[this.name].call(this);
    

    This will call WSFunctions[this.name] with this being set to what this refers to in the caller (in this case the instance created by new WS(...)).

    Also have a look at this page which thoroughly explains how this works.

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

Sidebar

Related Questions

I have the following code $('#first').click(function() { myVar = $(this).next().val(); }); $('#second').blur(function() { console.log(myVar);
$(document).ready(function(){ contM = $('#main-content'); contS = $('#second-content'); $(contM).hide(); $(contS).hide(); function loadURL(url) { console.log(loadURL: +
The function down here get's called every second, it only never outputs: console.log(noise: +noise);
This question is more on javascript principle. function done(){ console.log('done defined with `function done(){
I have a following (simplified) code: var myModule = { submitDummyForm: function(){ console.log(this); //
the second function isnt working? $('.edit_hover').live('hover', function(e){ $(this).stop(); var half_width = ($(this).css('width').slice(0, -2))/2; var
I'm using the: console.log() method to log messages to firefox (3.6.6)/firebug while working on
I just discovered that the following code executes without error (Chrome): console.log(fa); function fa(){}
I've been trying to troubleshoot this, but can't find a good function that will
Given the following code: if (string) { console.log('true!'); } //logs true to the console

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.