title: Incrementing Arrays in JS
body: <p>Im trying to make a list of messages with the latest at the top. This is in Node red. I have a 4 line LCD I wish to display Pager messages on</p>
  
  <p>To me this should work but it doesn't, Just shows the message in the last line and won't add new ones</p>
  
  <pre><code>var message = [];
  
  message.splice(4,0,msg.message);
  message.splice(0,1);
  
  msg.payload1 = message[0];
  msg.payload2 = message[1];
  msg.payload3 = message[2];
  msg.payload4 = message[3];
  return msg;
  </code></pre>
  
  <p>Here is the Node red flow</p>
  
  <pre><code>[{"id":"dd82941d.5b65c8","type":"function","z":"4cce1974.6fb398","name":"Format Pager Message","func":"var str = msg.payload;\nvar pager = str.substring(9,16);\nvar length = str.length - 2;\nvar message = str.substring(17,length);\nmsg.pager = pager;\nmsg.message = message;\nreturn msg;","outputs":1,"noerr":0,"x":311,"y":195,"wires":[["2b7dc9b1.c01356"]]},{"id":"188de5a3.ba258a","type":"rpi-lcd","z":"4cce1974.6fb398","name":"","pins":"12,7,8,25,24,23","x":1113,"y":195,"wires":[]},{"id":"f66dd00d.9b67e","type":"template","z":"4cce1974.6fb398","name":"","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"1:{{payload1}}\n2:{{payload2}}\n3:{{payload3}}\n4:{{payload4}}","x":942,"y":193,"wires":[["188de5a3.ba258a"]]},{"id":"d6971b25.349b38","type":"debug","z":"4cce1974.6fb398","name":"","active":true,"console":"false","complete":"true","x":717,"y":245,"wires":[]},{"id":"7ee7f56e.176e5c","type":"inject","z":"4cce1974.6fb398","name":"","topic":"test","payload":"0123456789abcdefgHello Worldyz","payloadType":"str","repeat":"","crontab":"","once":false,"x":115,"y":229,"wires":[["dd82941d.5b65c8"]]},{"id":"2b7dc9b1.c01356","type":"function","z":"4cce1974.6fb398","name":"Stack Messages","func":"var message = [];\n\nmessage.splice(4,0,msg.message);\nmessage.splice(0,1);\n\nmsg.payload1 = message[0];\nmsg.payload2 = message[1];\nmsg.payload3 = message[2];\nmsg.payload4 = message[3];\nreturn msg;","outputs":1,"noerr":0,"x":539,"y":194,"wires":[["f66dd00d.9b67e","d6971b25.349b38"]]}]
  </code></pre>