Q:

brackets and js expressions executiing

Can anyone explain me this expressions and how it works:
(1, 2, 3) //returns  3

next:
var foo = 0, bar = 'baz';
   (foo++,foo++, bar) // foo = 2, returns 'baz'

and:
var f = (function f(){ return "1"; }, function g(){ return 2; })();
typeof f; // returns number

As i undestand expressions inside brackers executings from left to right and then returning the last item? If so, why the last example returns number?? After the executing function f(){ return "1"; } it cought return string...

A:

(x, y, z) expression simply evaluates the arguments and return the last argument.
So in case (1, 2, 3) 1 is evaluated to 1, 2 is evaluated to 2, 3 is evaluated to 3 and it is returned.
Now in your second example:

var foo = 0, bar = 'baz';
   (foo++,foo++, bar) // foo = 2, returns 'baz'

it returns baz as bar is the last argument evaluated and returned. Meanwhile both foo++ are evaluated but not returned thus giving you foo value of 2.
NOW your last example is really simple but please don't use such an agony in practice.
Let me simplify your expression into:

var f = (function f(){ return "1"; }, function g(){ return 2; })

By making it not self-executing. The first function is evaluated - good, the second is evaluated and returned. Now your f is simply function g(). As you wrap everything in () and immediately execute with another () you are simply doing g().
Let me break down the things a bit:

var f = (function f(){ return "1"; }, function g(){ return 2; })

f is equal to function g() { return 2; }
(f)() returns the function f and immediately executes it thus giving you 2 whith type is of course a Number.

