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
Continue with Google
or use

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
Continue with Google
or use

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

Sorry, you do not have permission to ask a question, You must login to ask a question.

Continue with Google
or use

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

Answerclub

Answerclub Logo Answerclub Logo

Answerclub Navigation

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

Mobile menu

Close
Ask A Question
  • Home
  • About Us
  • Contact Us

Welcome to Answerclub.org

Questions | Answers | Discussions | Knowledge sharing | Communities & more.

Ask A Question
Home/ Questions/Q 157730
Next
In Process

Answerclub Latest Questions

Aryan Prajapat
  • 0
  • 0
Aryan PrajapatKnowledge Contributor
Asked: July 21, 20242024-07-21T10:52:29+05:30 2024-07-21T10:52:29+05:30In: Education

What do you understand by “this” keyword in javascript?

  • 0
  • 0
What do you understand by “this” keyword in javascript?
1
  • 1 1 Answer
  • 33 Views
  • 0 Followers
  • 0
Answer
  • Report

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Aryan Prajapat
    Aryan Prajapat Knowledge Contributor
    2024-07-21T10:55:30+05:30Added an answer on July 21, 2024 at 10:55 am

    Ans: In JavaScript “this” keyword is widely used and it points to a specific object that is executing a current piece of code. It refers to the object that is executing the current function. If the function is a regular function, “this” refers to the global object. If the function referenced is a method in an object, “this” refers to the object itself.

    Below are the rules that apply to “this” keyword to know which object it is referencing:

    Global Scope
    If a function is called from a global scope which includes ‘this’ keyword, it will always point to the window object.

    For Example:

    //global declaration of num having global scope
    var num = 150;
    function global_this() {
    // local variable inside function has local scope
    var num = 250;
    alert(“mynum = ” + mynum); // answer is 250 called locally
    alert(“this.mynum = ” + this.mynum); // answer is 150 as “this” keyword points to //global variable i.e., window object.
    }
    global_this();

    Object’s Method
    By using a new keyword if an object is created then “this” will point to that specific object

    For example:

    // declaring global variables 100 has global scope
    var myNum = 100;
    function printNum() {
    this.myNum = 300;
    this.display = function () {
    var myNum = 400;
    alert(“myNum = ” + myNum); // 400
    alert(“this.myNum = ” + this.myNum); // 300
    };
    }
    var objM = new printNum();
    objM.display();

    “this” keyword inside the display() method of the object ‘objM’ will point to the value outside the scope of the display() method.

    call() or apply() method
    A function can be invoked using the () operator or using call() and apply the () method also. The main aim of call() and apply() is to set the context of “this” keyword inside a function regardless of whether that function is being called in the global scope or as an object’s method.

    bind() method
    The bind() method is used to set the context of ‘this’ keyword to a particular object when a function is invoked. It is mostly helpful in placing the context of this for a callback function.

    For example:

    var myNum = 50;

    function test() {

    alert(this.myNum);

    }

    var obj_1 = { myNum : 100 , demo1: test};

    var obj_2 = { myNum : 150 , demo1:test };

    test(); // ‘this’ will point to the global window object

    test.call(obj_1); // ‘this’ will point to obj_1

    test.apply(obj_2); // ‘this’ will point to obj_2

    obj_1.demo1.call(window); // ‘this’ will point to global window object

    test.apply(obj_2); // ‘this’ will point to obj_2

    //global scope of variable myNum

    var myNum = 200;

    function test(call)

    {

    //local scope of variable myNum

    var myNum = 250;

    call();

    };

    var obj1 = {

    myVar: 350,

    Thisfunc : function() {

    alert(“‘this’ points to myNum ” + this + “, myNum = ” + this.myNum);

    }

    };

    test(obj1.Thisfunc); //this points to the global window object

    test(obj1.Thisfunc.bind(obj1)); // setting “this” value using bind() method

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

You must login to add an answer.

Continue with Google
or use

Forgot Password?

Need An Account, Sign Up Here

Sidebar

Ask A Question

Stats

  • Questions 60,852
  • Answers 54,923
  • Popular
  • Answers
  • Mr.Doge

    What are the best AI tools available for Creative Designing?

    • 55 Answers
  • Mr.Doge

    How is tax calculated in India for investing in US ...

    • 42 Answers
  • Mr.Doge

    How to invest in NCD/ Corporate Bonds in India? Is ...

    • 38 Answers
  • acharyavijay shastri
    acharyavijay shastri added an answer If you are facing misunderstandings, family disagreements, communication problems, or… August 14, 2026 at 3:59 pm
  • dmktg39 singhal
    dmktg39 singhal added an answer Polyester Geogrid can be used in many civil engineering applications… August 14, 2026 at 3:20 pm
  • dmktg39 singhal
    dmktg39 singhal added an answer Polyester Geogrid helps reinforce weak or unstable ground by interacting… August 14, 2026 at 3:19 pm

Related Questions

  • Which crops commonly use Mulch Film, and how is it ...

    • 1 Answer
  • Which crops commonly use Mulch Film, and how is it ...

    • 0 Answers
  • Which industries commonly use Stretch Film for food and beverage ...

    • 1 Answer
  • Which crops and agricultural applications commonly use Mulch Film for ...

    • 1 Answer
  • B.Sc CS AI & Data Science vs BCA AI & ...

    • 1 Answer

Trending Tags

ai (253) biology (376) branch of study (241) business (241) car detailing studio (189) cricket (270) digital marketing (227) education (1096) english (343) food (303) general knowledge. (1051) general science (258) geography (269) gk (776) health (396) history (798) lifestyle (208) pilates (602) pilates classes (439) pilates fitness (573) pilates workout (557) poll (253) psychology (229) question (7894) science (352) sports (334) technology (394) tonic method (255) tonicmethod (212) travel (363)

Explore

  • Home
  • Groups
  • Add group
  • Catagories
  • Questions
    • New Questions
    • Most Answered
  • Polls
  • Tags
  • Badges

© 2026 Answerclub.org | All Rights Reserved
Designed & Developed by INFINITEBOX & TechTrends