Q: Why don't have to write conditional statement to determine whether input is object or array? A: because Object.keys behave similarly when input is input or object, It returns an array of index when input is an array. See below example from MDN doc.
var arr = ['a', 'b', 'c']; console.log(Object.keys(arr)); // console: ['0', '1', '2']