The exact syntax you want is not possible in JavaScript. The way JavaScript is executed should change quite fundamentally. For example:
var name = getUserById(id).andand().name;
However, JavaScript does not work. It just doesn’t.
The next line does almost what you want.
var name = (var user = getUserById(id)) ? user.name : null;
. :
// this is what you want to see
var initial = getUserById(id).andand().name.andand()[0];
// this is the best that JavaScript can do
var initial = (var name = (var user = getUserById(id)) ? user.name : null) ? name[0] : null;
. , . , , :
var name = (function() {return (var user = getUserById(id)) ? user.name : null;})();
, . ! !:)