Ole Ole - 1 year ago 71
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?


Answer Source

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);
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download