Javascript: Tips Jan 13, 2018 Define object with functions var extra = { myvar : "12", update : function(test) { var a = 'hello'; return a; }, ui: (function() { var ua = navigator.userAgent; return { IE: !!window.attachEvent && !isOpera, Opera: isOpera, WebKit: ua.indexOf('AppleWebKit/') > -1, Gecko: ua.indexOf('Gecko') > -1 && ua.indexOf('KHTML') === -1, MobileSafari: /Apple.*Mobile.*Safari/.test(ua) } })(), } () at the end of function == It’s just an anonymous function that is executed right after it’s created. It’s just as if you assigned it to a variable, and used it right after, only without the variable: var f = function () { }; f();