Debugger: Difference between revisions

Jump to navigation Jump to search
1,705 bytes added ,  6 December 2012
[master ac9906f] Doc Debugger.Object.prototype.displayName.
([whitespace af248e3] Remove trailing whitespace, to placate git.)
([master ac9906f] Doc Debugger.Object.prototype.displayName.)
Line 644: Line 644:


<dt>name
<dt>name
<dd>If the referent is a function, its function name. If the referent is an anonymous function, or not a function at all, this is <code>undefined</code>.
<dd>The name of the referent, if it is a named function. If the referent is an anonymous function, or not a function at all, return <code>undefined</code>.
 
This accessor returns whatever name appeared after the <code>function</code> keyword in the source code, regardless of whether the function is the result of instantiating a function declaration (which binds the function to its name in the enclosing scope) or evaluating a function expression (which binds the function to its name only within the function's body).
 
<dt>displayName
<dd>The referent's display name, if the referent is a function with a display name. If the referent is not a function, or if it has no display name, return <code>undefined</code>.
 
If a function has a given name, its display name is the same as its given name. In this case, the <code>displayName</code> and <code>name</code> properties are equal.
 
If a function has no name, SpiderMonkey attempts to infer an appropriate name for it given its context. For example:
  function f() {}          // display name: f (the given name)
  var g = function () {};  // display name: g
  o.p = function () {};    // display name: o.p
  var q = {
    r: function () {}      // display name: q.r
  };
 
Note that the display name may not be a proper JavaScript identifier, or even a proper expression: we attempt to find helpful names even when the function is not immediately assigned as the value of some variable or property. Thus, we use <code><i>a</i>/<i>b</i></code> to refer to the <i>b</i> defined within <i>a</i>, and <code><i>a</i>&lt;</code> to refer to a function that occurs somewhere within an expression that is assigned to <i>a</i>. For example:
  function h() {
    var i = function() {};    // display name: h/i
    f(function () {});        // display name: h/<
  }
  var s = f(function () {});  // display name: s<


<dt>parameterNames
<dt>parameterNames
Confirmed users
497

edits

Navigation menu