Dear colleagues
I'm not new to node-red, but I'm no programming experts neither.
While working on a flow, I tried to figure out how to create more than one message in a function node. I did read the documentation about the function node. And I thought I understood. But a very small tests showed me, that I don't.
Here is the test. I would be grateful for an explanation, why I can't duplicate an incoming message, change payload and topic, and create two different outgoing messages.
[{"id":"87c6db9f.4b9aa8","type":"inject","z":"b46b7fa0.7b04d","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"test1","payload":"1","payloadType":"num","x":320,"y":340,"wires":[["702af256.a9349c","e1e2c7bb.a1d0f8"]]},{"id":"702af256.a9349c","type":"function","z":"b46b7fa0.7b04d","name":"worsk as expected","func":"var msg1 = {};\nmsg1.topic = \"test2\";\nmsg1.payload = 2;\nreturn [msg, msg1];","outputs":2,"noerr":0,"initialize":"","finalize":"","x":540,"y":340,"wires":[["615b50d6.65b8f"],["7ac6ed31.699dc4"]]},{"id":"615b50d6.65b8f","type":"debug","z":"b46b7fa0.7b04d","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":790,"y":320,"wires":[]},{"id":"7ac6ed31.699dc4","type":"debug","z":"b46b7fa0.7b04d","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":790,"y":360,"wires":[]},{"id":"e1e2c7bb.a1d0f8","type":"function","z":"b46b7fa0.7b04d","name":"works in mysterious ways","func":"var msg1 = msg;\nmsg1.topic = \"test2\";\nmsg1.payload = 2;\nreturn [msg, msg1];","outputs":2,"noerr":0,"initialize":"","finalize":"","x":540,"y":420,"wires":[["db315194.668608"],["4b1a05c.59d27fc"]]},{"id":"db315194.668608","type":"debug","z":"b46b7fa0.7b04d","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":790,"y":400,"wires":[]},{"id":"4b1a05c.59d27fc","type":"debug","z":"b46b7fa0.7b04d","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":790,"y":440,"wires":[]}]