On this page:
function
return
this
call
new
6.1 Function Predicates
function?
constructor?
6.3.90.900

6 Functions

syntax

(function maybe-id (param-id ...) maybe-vars body ...+)

 
maybe-id = 
  | id
     
maybe-vars = 
  | #:vars (var-id ...)
Produces an ECMAScript function. Each parameter param-id is bound as a parameter in the ECMAScript environment, but is not bound as a Racket variable.

If id is provided, it is the name of the function.

If maybe-vars is provided, each var-id is initialized as an ECMAScript variable binding.

syntax

(return)

(return expr)
Return early from the enclosing function. If expr is provided it will be the return value. This form is illegal outside of a function body.

syntax

this

Binds to the ECMAScript this value for the current execution context.

procedure

(call ref arg ...)  (or/c value? void?)

  ref : function?
  arg : value?
Invokes the function from ref. Each arg is bound to a formal parameter of the function in order. Surplus arguments are ignored, and if insufficient arguments are passed the remaining parameters will be undefined.

The this value will be bound to the base of ref if it is a reference, or to the function itself otherwise.

procedure

(new ref arg ...)  object?

  ref : constructor?
  arg : value?
Invokes ref as a constructor, with each arg bound to a formal parameter. Surplus arguments are ignored, and any remaining parameters are bound to undefined.

6.1 Function Predicates

 (require ecmascript/function) package: ecmascript

procedure

(function? v)  boolean?

  v : any/c
Returns #t if v is an ECMAScript function, #f otherwise.

procedure

(constructor? v)  boolean?

  v : any/c
Returns #t if v is an ECMAScript function which can be used in a new expression, #f otherwise.