Ole Ole - 4 months ago 7
Javascript Question

What does the expression {headers : headers} evaluate to?

I'm reading through a tut-spring-security-and-angular-js Tutorial and it contains the following expression line:

$http.get('user', {headers : headers}).then(function(response)


What does the
{headers : headers}
expression evaluate to?

TIA,
Ole

Answer

It's an object literal with one propetry headers equal to whateever is stored under variable named headers.

A little easier to understand example:

var someValue = "aaa";
var myObject = {
  someKey: someValue 
};

var headers = "abcdef";
var secondParameter = {
  headers: headers
};

$.get("...", secondParameter);