What is the Definition of Operator in Computer Language?

By Xah Lee. Date: . Last updated: .

Operator is not well defined in programing languages. In math, we think of operators as notation for function. Typically, they have symbol forms, such as + - * / =.

[see What is Function, What is Operator?]

In programing languages, operator is not well defined.

in JavaScript, comma , is an operator, but not the comma in array.

js comma operator 2018 01 14 79472
JavaScript Comma Operator. ECMAScript® 2016 Language Specification, 12.16

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.key and typeof in typeof obj, and in in key in obj, are all considered as operators in JavaScript spec.

js assignment operator 2018 01 14 76649
JavaScript Assignment Operator. ECMAScript® 2016 Language Specification, 12.15
js new operator 2018 01 14 76244
JavaScript new Operator. ECMAScript® 2016 Language Specification, 12.3.3

The ternary if expression (test ? true_expr : false_expr), JavaScript calls it “conditional operator”.

js conditional operator 2018 01 14 24149
JavaScript Conditional Operator. ECMAScript® 2016 Language Specification, 12.14

However, the var in var x; is considered a statement.

js var statement 2018 01 14 7808
JavaScript var statement. ECMAScript® 2016 Language Specification, 13.3.2

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

See also: JavaScript in Depth

Programing Language Operators