Guard against undefined/null obj. Use hasOwnProperty from Object prototype to guard against possible overridden hasOwnProperty on obj.