Search Posts

Why I get "Invalid left-hand side in assignment"?

There is code:

function search(list, q){
  var result = {};
  for(let id in list)(
    (!q.id    || (id == q.id)) &&
    (!q.name  || (list[id].name.search(q.name) > -1)) &&
    result[id] = list[id]
  );

  return result;
}

I get this error:

Uncaught ReferenceError: Invalid left-hand side in assignment    script.js:4

Why “&&” is wrong?

Source: AngularJS

1 comment on Why I get "Invalid left-hand side in assignment"?

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.