From 649ff070d87c62d6cdbd40fb8c5614f1c3f43798 Mon Sep 17 00:00:00 2001 From: Teascade Date: Sun, 27 Aug 2017 00:14:43 +0000 Subject: [PATCH] Add two new assignment operators --- README.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/README.md b/README.md index 7431492..2856090 100644 --- a/README.md +++ b/README.md @@ -140,6 +140,25 @@ For example: If you however try to use these kinds of assignment operators on variabes which have not been initialized with a value yet, an exception will occur. +There are also two kinds of "special" assignment operators: +- `++` increment unary operator functions like `+= 1` +- `--` decrement unary operator functions like `-= 1` + +for example: +``` +let i = 0; +let first = i++; // first becomes 0, i increments to 1 +let second = i--; // second becomes 1, i decrements back to 0. +``` + +All assignment operators return the value the assignee (leftside of the operator) was before the operator. For more examples: + +``` +let test = 0; +let new = (test = 2); // new becomes 0, test becomes 2 +let another = (new += 5); /// another becomes 0, new becomes 5. +``` + ## Scopes Scopes are areas of code surrounded by brackets `{}`. E.g. ```