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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T01:03:29+00:00 2026-06-15T01:03:29+00:00

Consider the example: http://docs.sencha.com/ext-js/4-1/#!/api/Ext.app.Application-static-method-getName Ext.define(‘My.cool.Class’, { constructor: function() { alert(this.self.getName()); // alerts ‘My.cool.Class’ }

  • 0

Consider the example:

http://docs.sencha.com/ext-js/4-1/#!/api/Ext.app.Application-static-method-getName

Ext.define('My.cool.Class', {
    constructor: function() {
        alert(this.self.getName()); // alerts 'My.cool.Class'
    }
});

My.cool.Class.getName(); // 'My.cool.Class'

What is the self referring to in this example?
How can I, in this documentation, know when to use this and when self and when this.self?
Why this is not working:

this.getName()

or

self.getName()

My thoughts about this are that self refers to the class of the object so the only reason I need to do this is because the getName() method is static so I’m (kinda) not calling it from object, but from class. Am I right? Am I? Ha? Ha? Am I? 😀

  • 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-15T01:03:30+00:00Added an answer on June 15, 2026 at 1:03 am

    this.self refers to the class object. It means that this.self === My.cool.Class. So you can instantiate new My.cool.Class object by invoking new this.self().

    The reason why this.getName() doesn’t work is because in JS static properties/methods are not available in instance.

    Example:

    var Class = function(){};
    Class.prototype = {};
    
    Class.staticMethod = function(){ alert('static method'); };
    Class.prototype.instanceMethod = function(){ alert('instance method'); };
    
    var instance = new Class();
    
    Class.staticMethod(); // works
    Class.instanceMethod(); // doesn't work
    
    instance.staticMethod(); // doesn't work
    instance.instanceMethod(); // works
    

    Also static properties/methods are not available in sub class even in static context.

    Example:

    Ext.define('One', {
        instanceMethod: function() { alert('Instance One'); }
    });
    Ext.apply(One, {
        staticMethod: function() { alert('Static One'); }
    });
    
    
    Ext.define('Two', {
        extend: 'One'
    });
    
    
    One.staticMethod(); // works
    Two.staticMethod(); // doesn't work
    

    The reason why getName method is available in My.cool.Class is because there are copied from Ext.Base class in ExtClass.create method (this class is private, it’s not visible in API).
    ​

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

Sidebar

Related Questions

Consider this example: http://docs.sencha.com/ext-js/4-0/#!/example/grid/binding-with-classes.html I want handle 'selectionchange' event in the controller. Like following
Consider the following example code: http://code.google.com/apis/maps/documentation/javascript/examples/streetview-simple.html I can do scrollwheel: false on a mapOptions
Consider this example showing the YUI tree in action: http://developer.yahoo.com/yui/examples/treeview/tv_edit.html Select the title in
I'm reading this: http://java.sun.com/docs/books/jls/third_edition/html/expressions.html#15.20.2 They say: Consider the example program: class Point { int
Consider this example: http://jsfiddle.net/treeface/P8JbW/ HTML : <div id=test> <img src=http://ycombinator.com/images/y18.gif /> </div> CSS :
Consider the following example taken from http://www.albahari.com/threading/ : using System; using System.Threading; class ThreadTest
From http://java.sun.com/docs/books/performance/1st_edition/html/JPAppGC.fm.html#99740 example A3.3 says, it says that an object might still not be
Let's consider an example <?xml version=1.0 encoding=utf-8?> <s:WindowedApplication xmlns:fx=http://ns.adobe.com/mxml/2009 xmlns:s=library://ns.adobe.com/flex/spark xmlns:mx=library://ns.adobe.com/flex/mx xmlns:local=*> <s:Button id=button/>
Consider following two examples: Example 1: <xs:import namespace=http://example.com/ns schemaLocation=test.xsd/> Example2: <sample:Data Test=true xsi:schemaLocation=http://example.com/test.xsd> How
Consider a webpage, located at http://www.example.com/mypage.html Unfortunately, someone wrongly advertises that the page's address

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.