Basic JavaScript: Record CollectionPassed

I understand the provided solution except one bit… How does this or || part work??

collection[id][prop] = collection[id][prop] || ;

function updateRecords(id, prop, value) {
  if(value === "") delete collection[id][prop];
  else if(prop === "tracks") {
    collection[id][prop] = collection[id][prop] || [];
  } else {
    collection[id][prop] = value;

  return collection;

Hello there,

In JavaScript, || is an operator that returns the first truthy value.

So, in your case: collection[id][prop] is returned if it exists. If it does not exist, then it is evaluated as a falsey value, and the alternate will be returned - []

You can read more about it here:

Hope this helps