Skip to content

Commit

Permalink
fix format
Browse files Browse the repository at this point in the history
  • Loading branch information
loverajoel committed Aug 10, 2016
1 parent 151408c commit 3c913ef
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion _posts/en/2016-08-10-comma-operaton-in-js.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,15 @@ categories:
---
Apart from being just a delimiter, the comma operator allows you to put multiple statements in a place where one statement is expected.
Eg:-

```js
for(var i=0, j=0; i<5; i++, j++, j++){
console.log("i:"+i+", j:"+j);
}
```

Output:-

```js
i:0, j:0
i:1, j:2
Expand All @@ -30,6 +32,7 @@ i:4, j:8
When placed in an expression, it evaluates every expression from left to right and returns the right most expression.

Eg:-

```js
function a(){console.log('a'); return 'a';}
function b(){console.log('b'); return 'b';}
Expand All @@ -40,6 +43,7 @@ var x = (a(), b(), c());
console.log(x); // Outputs "c"
```
Output:-

```js
"a"
"b"
Expand All @@ -52,5 +56,5 @@ Output:-

##### Playground
<div>
<a class="jsbin-embed" href="https://jsbin.com/vimogap/embed?js,console">JS Bin on jsbin.com</a><script src="http://static.jsbin.com/js/embed.min.js?3.39.11"></script>
<a class="jsbin-embed" href="http://jsbin.com/vimogap/embed?js,console">JS Bin on jsbin.com</a><script src="http://static.jsbin.com/js/embed.min.js?3.39.11"></script>
</div>

0 comments on commit 3c913ef

Please sign in to comment.