I was reading some code for a challenge I'm working on, and going this.
function updateRecords(id, prop, value) { if (value === '') { delete collection[id][prop]; } else { if (prop !== 'tracks') { collection[id][prop] = value; } else { collection[id].hasOwnProperty('tracks') ? collection[id].tracks.push(value) : collection[id].tracks = [value]; } } return collection; }
What does . hasOwnProperty ('tracks') ? do? Why the question mark, and why the colon. Does it set instructions based on Boolean value of hasOwnProperty?