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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T13:57:08+00:00 2026-05-31T13:57:08+00:00

I am trying to understand the difference of using the keyword this or rather

  • 0

I am trying to understand the difference of using the keyword “this” or rather what it represents in jQuery Vs an MVC framework like Backbone.

Below are 2 code samples of each;
So in jQuery, we have

$("#result").click(function(){
$(this).html(someval);
})

In Backbone, we have code as;

var HandlebarsView = Backbone.View.extend({
el: '#result'
initialize: function(){
this.template = Handlebars.compile($('#template').html());     
},
render: function(){
var html = this.template(this.model.toJSON());
this.$el.html(html);
}
});

Now I do understand that “this” refers to the DOM element in jQuery.

I wanted to understand what it represents in case of the Backbone code.

Please let me know.

  • 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-31T13:57:09+00:00Added an answer on May 31, 2026 at 1:57 pm

    this is the context in which a function executes.

    The trick to understanding this is understanding that it’s the way you execute a function that determines it.

    When you pass a function to a method like jQuery, you are using that function as a callback method. jQuery explicitly sets the context of the callback when it executes.

    When you call a method on an object using the dot-notation: myView.render() it’s the dot-notation that explicitly sets the context of the method call to the object in front of the dot.

    The rules for what a context is set to are pretty simple in JavaScript, but can cause a lot of confusion. Most languages set the self-referencing context variable to the object that the method was defined in. JavaScript, though, uses the method invocation pattern to determine the context.

    When we pass a any object’s method around as a callback method, the code that calls it sets the context of the method – this includes Backbone’s views and other objects. You can explicitly override this by using Underscore.js’ bind and bindAll functions ( http://documentcloud.github.com/underscore/#bind ), as well as a few other tricks.

    
    Backbone.View.extend({
      initialize: function(){
        _.bindAll(this);
      }
    });
    

    This code, for example, will bind the context of all the functions on the current view object, to the view. This guarantees that the context of your view methods will always be the view itself.

    For more info see:

    • http://es5.github.com/ – annotated ES5 specification
    • http://yehudakatz.com/2011/08/11/understanding-javascript-function-invocation-and-this/
    • http://lostechies.com/derickbailey/2011/06/15/solving-backbones-this-model-view-problem-with-underscore-js/
    • http://www.watchmecode.net/javascript-context (my own screencast covering all the rules and how to use them – a paid screencast)
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to understand the difference between this: if (isset($_POST['Submit'])) { //do something
I am trying to understand the difference between this list: UIRequiredDeviceCapabilities and individual keys
Been trying my best to understand this correctly. What is the difference between an
I am trying to understand this particular difference between the direct and delegated event
I am trying to understand the concept of synchronizing on an object. Using this
I'm trying to understand the difference between using a UINavigationController inside a Nib (via
I'm trying to understand 2 different lines of code below. My javascript is weak,
I'm trying to understand the difference between a squash and a rebase. As I
I'm trying to understand the difference between sequences and lists. In F# there is
I am trying to understand the difference between 2 methods that have the same

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.