#!/usr/bin/node var key = 'id'; var obj = { id: 123, key: "wrong key!" }; function do_meth( obj, key ) { return obj.key; } function do_windex( obj, key ) { return obj[key]; } console.log( do_meth( obj, key ) ); console.log( do_windex( obj, key ) );