Interesting. But I'm a little confused about your usage example.
You have chain.val = val
but as far as I can tell that will just resolve to undefined?
Hey, check the functions below of it. "val" is defined as the last function in that scope. You may want to search for "function hoisting" if it looks weird for you.