JS1159: Syntax error. Use 'static classname {...}' to define a class initializer

A code block immediately follows a modifier inside a class. JScript modifiers can only be applied to class members. Two likely scenarios might produce this result:

  • You meant to define a class initializer but left out the class name.

  • You meant to define a method or property accessor but left out the function, function get, or function set statement.

To correct this error

  1. If you meant to define a class initializer, use the correct syntax for static statement.

  2. If you meant to define a method or property accessor, use the correct syntax for the function, function get, or function set statement.

See Also

Concepts

Troubleshooting Your Scripts

JScript Modifiers

Reference

static Statement

function Statement

function get Statement

function set Statement

Other Resources

JScript Reference