Msg.topic msg.payload syntax

Having read all through the forum and having read the node-red docs on functions and such I haven't found a clear answer to my question. This isn't related to a flow problem or a current project but for some reason this came to me and I'm trying to determine the answer.
So if I put in if (msg.topic == 'test' && msg.payload == 'test') { some answer}
does this pull from the same message and topic. In other words if there are several messages in the node and one message has the topic of 'test' but the payload is 'none' and another message has the topic of 'next' and a payload of 'test' would the syntax above return a true? In my limited testing over several days it would which is not what I'm looking for. I want the topic and payload from the same message. Can / would someone point me in the right direction please?
thanks in advance

There can only ever be one msg.whatever (topic,payload,xyz etc). The value of "whatever" will be what it was last assigned.

If you need to work on more than one message in a function node then you would have something like msg, msg2, msg3 ...

Though Bobo did answer, I feel I should chip in here too.

Node-red is what I would call "event driven".

So something happens when a message arrives at the input of a node.

Keeping it simple, the "message" has a payload and a topic.

So when it arrives at the node's input there is only that message as far as the node is concerned.

There are ways to allow it to see more, but that is beyond the scope here and now.

So you are correct in this request.

It would be for the one message at that point in time.

Good luck.



Neither message would return true.

The first one does not match because payload is 'none' and the second one does not match because topic is 'next' so your AND fails in both cases