Set app variables using javascript

How can we set app variables from javascript like {!loggedInUserRoles!}. Is there any work around to achieve this.