Swift and JavaScript comparison snippets(2) — Basic Operators

unbug
HackerNoon.com
4 min readJun 27, 2018

--

Assignment Operator

Swift

JavaScript

Arithmetic Operators

  • Addition (+)
  • Subtraction (-)
  • Multiplication (*)
  • Division (/)

Swift

JavaScript

Remainder Operator

Swift

JavaScript

Unary Minus/Plus Operator

Swift

JavaScript

Compound Assignment Operators

Swift

JavaScript

Comparison Operators

  • Equal to (a == b)
  • Not equal to (a != b)
  • Greater than (a > b)
  • Less than (a < b)
  • Greater than or equal to (a >= b)
  • Less than or equal to (a <= b)
  • Identity operators, refer to the same object instance (a === b)
  • Identity operators, not refer to the same object instance (a !== b)

Swift

JavaScript

Ternary Conditional Operator

Swift

JavaScript

Logical Operators

  • Logical NOT (!a)
  • Logical AND (a && b)
  • Logical OR (a || b)

Swift

JavaScript

More of Swift and JavaScript comparison snippets

--

--