Cant understand deny and update call parameters

Hi everyone
I m trying to understand this code.
I have 2 questions.
1st question —I don’t get the idea on how the deny call receives all parameter details although we don’t pass the parameter details.

  update: function(userId, post, fieldNames) {
    // may only edit the following two fields:
    return (_.without(fieldNames, 'url', 'title').length > 0);

  update: function(userId, post, fieldNames, modifier) {
    var errors = validatePost(modifier.$set);
    return errors.title || errors.url;

2nd question ----- what does fieldNames.length === 1 && fieldNames[0] === ‘read’ means?

	update: function(userId,doc,fieldNames)
		return ownsDocument(userId,doc) && fieldNames.length === 1 && fieldNames[0] === 'read';

Thank you

Hi @gvimlan.

I can’t answer your first question, because I don’t know, but I can answer the second one!

The === means “equal value and equal type”. In JavaScript 2 == "2" is true but 2 === "2" is false. Try it in the browser’s console. In Chrome you can press Ctrl+Shift+J (on Windows, don’t know Mac.)

In the line of code you referenced, fieldNames.length is the “length” of the variable fieldNames. (Length being how many characters in a string or number of elements in an array.) fieldNames[0] is a reference to the first element in the array called fieldNames. By adding the [0] the browser is asking the variable fieldNames for the content of the first element in the array. So to put it all together, that line is asking…

Is the length of the variable fieldNames equal to the number 1 AND is the first value of the array fieldNames a string of 'read'?

Someone please correct me wherever I went wrong.

p.s. Your future questions will be much easier to read if you choose to format them properly. Use a backtick ` at the beginning and ending of a string to make it look like this. e.g. `this`

And indent all your individual lines of code with four spaces to make them


The framework (Meteor) is taking care of that for you. To use it, you don’t need to understand how, but if you want you can check it out in the source code.