var a; function getA() { if (typeof(a) == 'undefined') { a = 1 + 1; } return a; } var b = getA(); var c = getA();