Function in ECMAScript 262

The object representing functions and methods.

Inherits from:

Instance Properties

name type description
arguments Array An array of all parameters passed to the function/method.
constructor Object A reference to the constructor class for the current object instance. [from Object]
length Number (read only) The number of arguments declared with the function.
prototype Object The prototype for a class. [from Object]

Instance Methods

name returns description
apply([thisScope],[args]) Object Call the function/method, optionally setting a new scope for this and passing in parameters via an array.
call([thisScope],[arg1],[arg2],…) Object Call the function/method, optionally setting a new scope for this and passing in parameters.
hasOwnProperty(propertyOrMethodName) Boolean Determines if the object/instance itself has the named property or method. [from Object]
isPrototypeOf(instanceToTest) Boolean Determines if the calling object prototype is in the inheritance chain for the supplied argument. [from Object]
propertyIsEnumerable(propertyOrMethodName) Boolean Determines if the object/instance itself has a property or method of the supplied name which will appear in a for (prop in obj) enumeration. [from Object]
toLocaleString() String For most objects, the same as toString() unless explicitly overridden. [from Object]
toString() String Returns a string representation of the object. [from Object]
valueOf() String Returns the internal this value of the object. [from Object]

Methods that return a Function

name of object description
ease(easingType,[easeParam1],[easeParam2]) d3 Retrieve a predefined easing function.

Arguments that are a Function

name in method of object description
comparator sort(comparator) [d3] Selection This function is passed two data elements a and b to compare, and must return either a negative number, positive number, or zero. If negative, then a should be before b; if positive, then a should be after b; if zero, a and b are considered equal and the order is arbitrary.
compareFunction sort([compareFunction]) Array The comparison function to use
dataCalculator data(dataCalculator,[keyCalculator]) [d3] Selection
delayCalculator delay(delayCalculator) [d3] Transition Invoked for each element in the transition selection, passed the element’s datum, index, and with the this context set to the element. The return value is set as the transition delay for the element, in milliseconds.
durationCalculator duration(durationCalculator) [d3] Transition Invoked for each element in the transition selection, passed the element’s datum, index, and with the this context set to the element. The return value is set as the transition duration for the element, in milliseconds.
easingFunction ease(easingFunction) [d3] Transition
eventHandler on(eventName,eventHandler,capturePhase) [d3] Selection Function to be invoked when the event occurs. Will be passed the datum for the current object, the index of that object in the selection, and with the this context set to the DOM element. To remove an event handler, pass null for this parameter.
func each(func) [d3] Selection Invoked for each element in the selection, passed the datum and index, with the this context set to the DOM element.
func property(name,func) [d3] Selection The function is evaluated for each selected element (in order), being passed the current datum d and the current index i, with the this context as the current DOM element. The function’s return value is then used to set each element’s property.
func attr(name,func) [d3] Transition Invoked for each element in the transition selection, passed the current datum and index, with the this context as the current DOM element. The function’s return value is used to set each attribute’s value at the end of the transition. A null value will not remove the specified attribute.
func call(func,[arg1],[arg2],…) [d3] Transition Invoked and passed the transition (and any additional arguments); the this context is also set to the transition.
func each([type],func) [d3] Transition Invoked for each element in the seleciton, with parameters for the datum and index, and with the this context set to the DOM element.
func classed(name,func) [d3] Selection The function is evaluated for each selected element (in order), being passed the current datum d and the current index i, with the this context as the current DOM element. The function’s return value is then used to assign or unassign the specified class on each element.
func style(name,func,[priority]) [d3] Selection The function is evaluated for each selected element (in order), being passed the current datum d and the current index i, with the this context as the current DOM element. The function’s return value is then used to set each element’s style property. A null value will remove the style property
func text(func) [d3] Selection The function is evaluated for each selected element (in order), being passed the current datum d and the current index i, with the this context as the current DOM element. The function’s return value is then used to set each element’s text content. A null value will clear the content.
func style(name,func,[priority]) [d3] Transition Invoked for each element in the transition selection, passed the current datum and index, with the this context as the current DOM element. The function’s return value is used to set the element’s CSS property value at the end of the transition. A null value will not remove the specified style.
func call(func,[arg1],[arg2],…) [d3] Selection Invoked and passed the selection (and any additional arguments); the this context is also set to the selection.
func html(func) [d3] Selection The function is evaluated for each selected element (in order), being passed the current datum d and the current index i, with the this conhtml as the current DOM element. The function’s return value is then used to set each element’s html content. A null value will clear the content.
func attr(name,func) [d3] Selection The function is evaluated for each selected element (in order), being passed the current datum d and the current index i, with the this context as the current DOM element. The function’s return value is then used to set each element’s attribute. A null value will remove the specified attribute.
func text(func) [d3] Transition Invoked for each element in the transition selection, passed the current datum and index, with the this context as the current DOM element. The function’s return value is used to set the element’s textContent at the start of the transition. A null value will clear the content.
func datum(func) [d3] Selection This function is invoked for each selected element, being passed the previous datum d and the current index i, with the this context as the current DOM element. The return value of this function is used to set each element’s data. A null value will delete the bound data.
keyCalculator data(dataCalculator,[keyCalculator]) [d3] Selection This function is yielded the values of the array and must return a unique string for each.
keyCalculator data(dataValues,[keyCalculator]) [d3] Selection This function is yielded the values of the array and must return a unique string for each.
selectCalculator select(selectCalculator) [d3] Selection Invoked for each entry in the selection, with parameters for the current datum and index, and with the this context as the current DOM element. Must return either an element or null.
selectCalculator selectAll(selectCalculator) [d3] Selection Invoked for each entry in the selection, with parameters for the current datum and index, and with the this context as the current DOM element. Must return either an array or NodeList (either of which may be empty).
tweenCalculator attrTween(name,tweenCalculator) [d3] Transition Invoked for each element in the transition selection at the start of the transition, passed the current datum, index, and current (pre-transition) attribute value, with the this context as the current DOM element. This function must then return a tween interpolator function to use during the transition; the interpolator will be passed parameterized time in the domain [0,1] and must return the desired attribute value.
tweenCalculator tween(name,tweenCalculator) [d3] Transition Invoked for each element in the transition selection at the start of the transition, passed the current datum, index, and current (pre-transition) attribute value, with the this context as the current DOM element. This function must then return a tween interpolator function to use during the transition; the interpolator will be passed parameterized time in the domain [0,1] with the this context set to DOM element, and must do whatever is necessary to accomplish the tween.
tweenCalculator styleTween(name,tweenCalculator,[priority]) [d3] Transition Invoked for each element in the transition selection at the start of the transition, passed the current datum, index, and current (pre-transition) calculated CSS value, with the this context as the current DOM element. This function must then return a tween interpolator function to use during the transition; the interpolator will be passed parameterized time in the domain [0,1] and must return the desired CSS style value.