Q:

Returning Values in Javascript Functions

I came across this answer while understanding closures by @Jacob Swartwood https://stackoverflow.com/a/6472397/3179569
and I could not understand how littleGirl called story as if it was a function. Shouldn't it have been littleGirl(); so that the princess function was called? Also isn't the princess function returning a key value pair, which means it's returning an object? So how can littleGirl access a key as if it was a function? (because story is a key right?) 
I tried searching for the term returning a key value pair in javascript but didn't come up with a decent explanation. I'm hoping someone here can help me. I come with a background in Java and C++ so this is a bit confusing. 
function princess() {

    var adventures = [];

    function princeCharming() { /* ... */ }

    var unicorn = { /* ... */ },
        dragons = [ /* ... */ ],
        squirrel = "Hello!";

    return {

        story: function() {
            return adventures[adventures.length - 1];
        }
    };
}

var littleGirl = princess();

littleGirl.story();

A:

Maybe if we break it down and add one thing at a time it will make more sense.
First, a function princess that returns undefined:
function princess() {
}

princess();

//> undefined

Next, a function that returns an object literal:
function princess() {
    return {};
}

princess();

//> Object {}

Next, a function that returns an object literal with a function inside it (which returns undefined):
function princess() {
    return {
        story: function {}
    };
}

princess().story();

//> undefined

Next, a function that returns an object literal with a function inside that returns an array:
function princess() {
    return {
        story: function {
            return [];
        }
    };
}

princess().story();

//> Array []

I think that covers most of your points.  However, none of this has much to do with closures.  In your example, the array adventures is what is being closed over.  This allows kind of a private member (like with access modifier in Java).
So, finally, a function that returns an object literal with a function inside which closes over a private array:
function princess() {
    var myArray = [1, 2, 3];
    return {
        story: function {
            return myArray[myArray.length - 1];  // get the last one: 3
        }
    };
}

princess().story();

//> 3

