Operators

  • Revision slug: JavaScript/Reference/Operators
  • Revision title: Operators
  • Revision id: 68622
  • Created:
  • Creator: pig_knuckle_sandwich
  • Is current revision? No
  • Comment all assignment operators; 12 words added, 21 words removed

Revision Content

Arithmetic Operators

(+, -, *, /, %, ++, --, unary -, unary +)

Arithmetic operators take numerical values (either literals or variables) as their operands and return a single numerical value.

Assignment Operators

(=, *=, /=, %=, +=, -=, <<=, >>=, >>>=, &=, ^=, |=)

An assignment operator assigns a value to its left operand based on the value of its right operand.

Bitwise Operators

(&, |, ^, ~, <<, >>, >>>)

Bitwise operators treat their operands as a set of 32 bits (zeros and ones) and return standard JavaScript numerical values.

Comparison Operators

(==, !=, ===, !==, >, >=, <, <=)

A comparison operator compares its operands and returns a logical value based on whether the comparison is true.

Logical Operators

(&&, ||, !)

Logical operators are typically used with boolean (logical) values, and when they are, they return a boolean value.

String Operators

(+ and +=)

The string operators concatenate two string values together, returning another string that is the union of the two strings.

Member Operators

(object.property and object{{ mediawiki.external('\"property\"') }})

Member operators provide access to a property or method of an object.

Special Operators
There are several special operators that do not fit into any other category:
Conditional Operator

(condition ? ifTrue : ifFalse)

The conditional operator returns one of two values based on the logical value of the condition.

Comma Operator

(,)

The comma operator allows multiple expressions to be evaluated in a single statement and returns the result of the last expression.

delete Operator

(delete)

The delete operator deletes objects.

function Operator

(function)

The function operator defines a function.

get Operator

(get)

The get operator defines a property to be a getter.

in Operator

(in)

The in operator determines whether an object has a given property.

instanceof Operator

(instanceof)

The instanceof operator determines whether an object is an instance of another object.

let Operator

(let)

The let operator temporarily assigns a value to a variable that only effects an expression.

new Operator

(new)

The new operator creates an instance of a constructor.

set Operator

(set)

The set operator defines a property to be a setter.

this Operator

(this)

The this operator refers to the execution context.

typeof Operator

(typeof)

The typeof operator determines the type of a given object.

void Operator

(void)

The void operator discards an expressions return value.

yield Operator

(yield)

The yield operator determines what is returned in a generator by that generator's iterator.

Operator Precedence
Operator precedence defines the order in which operators are evaluated.

{{ languages( { "es": "es/Referencia_de_JavaScript_1.5/Operadores", "fr": "fr/R\u00e9f\u00e9rence_de_JavaScript_1.5_Core/Op\u00e9rateurs", "ja": "ja/Core_JavaScript_1.5_Reference/Operators", "pl": "pl/Dokumentacja_j\u0119zyka_JavaScript_1.5/Operatory" } ) }}

Revision Source

<dl> <dt><a href="/en/JavaScript/Reference/Operators/Arithmetic_Operators" title="en/JavaScript/Reference/Operators/Arithmetic_Operators">Arithmetic Operators</a></dt> <dd> <p>(<code>+</code>, <code>-</code>, <code>*</code>, <code>/</code>, <code>%</code>, <code>++</code>, <code>--</code>, unary <code>-, unary +</code>)</p> <div class="noinclude"> <p>Arithmetic operators take numerical values (either literals or variables) as their operands and return a single numerical value.</p> </div> </dd> <dt><a href="/en/JavaScript/Reference/Operators/Assignment_Operators" title="en/JavaScript/Reference/Operators/Assignment_Operators">Assignment Operators</a></dt> <dd> <p>(<code><span style="font-family: Verdana,Tahoma,sans-serif;">=, *=, /=, %=, +=, -=, &lt;&lt;=, &gt;&gt;=, &gt;&gt;&gt;=, &amp;=, ^=, |=</span></code>)</p> <div class="noinclude"> <p>An assignment operator assigns a value to its left operand based on the value of its right operand.</p> </div> </dd> <dt><a href="/en/JavaScript/Reference/Operators/Bitwise_Operators" title="en/JavaScript/Reference/Operators/Bitwise_Operators">Bitwise Operators</a></dt> <dd> <p>(<code>&amp;</code>, <code>|</code>, <code>^</code>, <code>~</code>, <code>&lt;&lt;</code>, <code>&gt;&gt;</code>, <code>&gt;&gt;&gt;</code>)</p> <div class="noinclude"> <p>Bitwise operators treat their operands as a set of 32 bits (zeros and ones) and return standard JavaScript numerical values.</p> </div> </dd> <dt><a href="/en/JavaScript/Reference/Operators/Comparison_Operators" title="en/JavaScript/Reference/Operators/Comparison_Operators">Comparison Operators</a></dt> <dd> <p>(<code>==</code>, <code>!=</code>, <code>===</code>, <code>!==</code>, <code>&gt;</code>, <code>&gt;=</code>, <code>&lt;</code>, <code>&lt;=</code>)</p> <div class="noinclude"> <p>A comparison operator compares its operands and returns a logical value based on whether the comparison is true.</p> </div> </dd> <dt><a href="/en/JavaScript/Reference/Operators/Logical_Operators" title="en/JavaScript/Reference/Operators/Logical_Operators">Logical Operators</a></dt> <dd> <p>(<code>&amp;&amp;</code>, <code>||</code>, <code>!</code>)</p> <div class="noinclude"> <p>Logical operators are typically used with boolean (logical) values, and when they are, they return a boolean value.</p> </div> </dd> <dt><a href="/en/JavaScript/Reference/Operators/String_Operators" title="en/JavaScript/Reference/Operators/String_Operators">String Operators</a></dt> <dd> <p>(<code>+</code> and <code>+=</code>)</p> <div class="noinclude"> <p>The string operators concatenate two string values together, returning another string that is the union of the two strings.</p> </div> </dd> <dt><a href="/en/JavaScript/Reference/Operators/Member_Operators" title="en/JavaScript/Reference/Operators/Member_Operators">Member Operators</a></dt> <dd> <p>(<code>object.property</code> and <code>object{{ mediawiki.external('\"property\"') }}</code>)</p> <div class="noinclude"> <p>Member operators provide access to a property or method of an object.</p> </div> </dd> <dt>Special Operators</dt> <div class="noinclude"> <dd>There are several special operators that do not fit into any other category:</dd> </div> <dd> <dl> <dt><a href="/en/JavaScript/Reference/Operators/Special/Conditional_Operator" title="en/JavaScript/Reference/Operators/Special_Operators/Conditional_Operator">Conditional Operator</a></dt> <dd> <p>(<code><em>condition</em> ? <em>ifTrue</em> : <em>ifFalse</em></code>)</p> <div class="noinclude"> <p>The conditional operator returns one of two values based on the logical value of the condition.</p> </div> </dd> <dt><a href="/en/JavaScript/Reference/Operators/Special/Comma_Operator" title="en/JavaScript/Reference/Operators/Special_Operators/Comma_Operator">Comma Operator</a></dt> <dd> <p>(<code>,</code>)</p> <div class="noinclude"> <p>The comma operator allows multiple expressions to be evaluated in a single statement and returns the result of the last expression.</p> </div> </dd> <dt><a href="/en/JavaScript/Reference/Operators/Special/delete" title="en/JavaScript/Reference/Operators/Special_Operators/delete_Operator">delete Operator</a></dt> <dd> <p>(<code>delete</code>)</p> <div class="noinclude"> <p>The delete operator deletes objects.</p> </div> </dd> <dt><a href="/en/JavaScript/Reference/Operators/Special/function" title="en/JavaScript/Reference/Operators/Special_Operators/function_Operator">function Operator</a></dt> <dd> <p>(<code>function</code>)</p> <div class="noinclude"> <p>The function operator defines a function.</p> </div> </dd> <dt><a href="/en/JavaScript/Reference/Operators/Special/get" title="en/JavaScript/Reference/Operators/Special_Operators/get_Operator">get Operator</a></dt> <dd> <p>(<code>get</code>)</p> <div class="noinclude"> <p>The get operator defines a property to be a getter.</p> </div> </dd> <dt><a href="/en/JavaScript/Reference/Operators/Special/in" title="en/JavaScript/Reference/Operators/Special_Operators/in_Operator">in Operator</a></dt> <dd> <p>(<code>in</code>)</p> <div class="noinclude"> <p>The in operator determines whether an object has a given property.</p> </div> </dd> <dt><a href="/en/JavaScript/Reference/Operators/Special/instanceof" title="en/JavaScript/Reference/Operators/Special_Operators/instanceof_Operator">instanceof Operator</a></dt> <dd> <p>(<code>instanceof</code>)</p> <div class="noinclude"> <p>The instanceof operator determines whether an object is an instance of another object.</p> </div> </dd> <dt><a href="/en/JavaScript/Reference/Operators/Special_Operators/let_Operator" title="en/JavaScript/Reference/Operators/Special_Operators/let_Operator">let Operator</a></dt> <dd> <p>(<code>let</code>)</p> <div class="noinclude"> <p>The let operator temporarily assigns a value to a variable that only effects an expression.</p> </div> </dd> <dt><a href="/en/JavaScript/Reference/Operators/Special/new" title="en/JavaScript/Reference/Operators/Special_Operators/new_Operator">new Operator</a></dt> <dd> <p>(<code>new</code>)</p> <div class="noinclude"> <p>The new operator creates an instance of a constructor.</p> </div> </dd> <dt><a href="/en/JavaScript/Reference/Operators/Special/set" title="en/JavaScript/Reference/Operators/Special_Operators/set_Operator">set Operator</a></dt> <dd> <p>(<code>set</code>)</p> <div class="noinclude"> <p>The set operator defines a property to be a setter.</p> </div> </dd> <dt><a href="/en/JavaScript/Reference/Operators/Special/this" title="en/JavaScript/Reference/Operators/Special_Operators/this_Operator">this Operator</a></dt> <dd> <p>(<code>this</code>)</p> <div class="noinclude"> <p>The this operator refers to the execution context.</p> </div> </dd> <dt><a href="/en/JavaScript/Reference/Operators/Special/typeof" title="en/JavaScript/Reference/Operators/Special_Operators/typeof_Operator">typeof Operator</a></dt> <dd> <p>(<code>typeof</code>)</p> <div class="noinclude"> <p>The typeof operator determines the type of a given object.</p> </div> </dd> <dt><a href="/en/JavaScript/Reference/Operators/Special/void" title="en/JavaScript/Reference/Operators/Special_Operators/void_Operator">void Operator</a></dt> <dd> <p>(<code>void</code>)</p> <div class="noinclude"> <p>The void operator discards an expressions return value.</p> </div> </dd> <dt><a href="/en/JavaScript/Reference/Operators/Special_Operators/yield_Operator" title="en/JavaScript/Reference/Operators/Special_Operators/yield_Operator">yield Operator</a></dt> <dd> <p>(<code>yield</code>)</p> <div class="noinclude"> <p>The yield operator determines what is returned in a generator by that generator's iterator.</p> </div> </dd> </dl> </dd> <dt><a href="/en/JavaScript/Reference/Operators/Operator_Precedence" title="en/JavaScript/Reference/Operators/Operator_Precedence">Operator Precedence</a></dt> <dd>Operator precedence defines the order in which operators are evaluated.</dd>
</dl>
<div class="noinclude">
<p>{{ languages( { "es": "es/Referencia_de_JavaScript_1.5/Operadores", "fr": "fr/R\u00e9f\u00e9rence_de_JavaScript_1.5_Core/Op\u00e9rateurs", "ja": "ja/Core_JavaScript_1.5_Reference/Operators", "pl": "pl/Dokumentacja_j\u0119zyka_JavaScript_1.5/Operatory" } ) }}</p>
</div>
Revert to this revision