What's the Definition of Operator in Computer Language?

By Xah Lee. Date: . Last updated: .

operator is not well defined in programing languages. Sometimes it's just part of syntax. e.g. the comma in JavaScript.

in js, comma , is an operator, but not the comma in array. here's the spec ECMAScript 2015 §ECMAScript Language: Expressions#sec-comma-operator

the equal character =, such as x = 4, is also an operator. But it could just be said as syntax.

Similarly, the new in new Date(), and delete in delete obj.prop and typeof in typeof obj, and in in prop in obj, are all considered as operators in js spec.

The ternary if expression (test ? true_expr : false_expr), JavaScript calls it “conditional operator”. ECMAScript 2015 §ECMAScript Language: Expressions#sec-conditional-operator

however, the var in var x; is considered a statement. ECMAScript 2015 §ECMAScript Language: Statements and Declarations#sec-ecmascript-language-statements-and-declarations

there does not seem to be a absolute definition that qualify something to be operator or just syntax or “statement”.

See also: