I'm following along the Discover Meteor tutorial and after commit 8-1 we add:
// Check that the userId specified owns the documents
ownsDocument = function(userId, doc) {
return doc && doc.userId === userId;
}
What I don't understand is that doc and userId are not strictly equal (===), so why does this work?
For reference:
doc:
{ _id: '1a2b3c4d',
url: 'blahblah.com',
title: 'blah blah',
userId: '0w9x8y7z',
author: 'testuser',
submitted: '...'}
doc.userId:
userId: 0w9x8y7z
userId:
userId: 0w9x8y7z
I get that doc.userId === userId
, but why would doc && doc.userId === userId
pass?