This .concat function does not work.
let device = {"spot1":{"value":
[1,1]
}};
let k = "spot1";
let value = [];
node.warn("value:" + value + ", typeof value:" + typeof value);
if (typeof device[k].value === 'number') {
node.warn("=number device[k].value:" + device[k].value);
value.push(device[k].value);
node.warn("=number value:" + value);
} else {
node.warn("=else device[k].value:" + device[k].value + ", typeof device[k].value:" + typeof device[k].value);
value.concat(device[k].value); // <-- this concat does not work
node.warn("=else value:" + value + ", typeof value:" + typeof value);
}
node.warn("value:" + value + ", typeof value:" + typeof value);
node.warn(device[k].value);
return msg;
example:
[
{
"id": "a48e4c1ee433cb0e",
"type": "function",
"z": "cbf7f47c.caccc8",
"name": "",
"func": "let device = {\"spot1\":{\"value\":\n[1,1]\n}};\nlet k = \"spot1\";\nlet value = [];\nnode.warn(\"value:\" + value + \", typeof value:\" + typeof value);\nif (typeof device[k].value === 'number') {\n node.warn(\"=number device[k].value:\" + device[k].value);\n value.push(device[k].value);\n node.warn(\"=number value:\" + value);\n} else {\n node.warn(\"=else device[k].value:\" + device[k].value + \", typeof device[k].value:\" + typeof device[k].value);\n value.concat(device[k].value); // <-- this concat does not work\n node.warn(\"=else value:\" + value + \", typeof value:\" + typeof value);\n}\nnode.warn(\"value:\" + value + \", typeof value:\" + typeof value);\nnode.warn(device[k].value);\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 3670,
"y": 4720,
"wires": [
[
"e92bb1ca62f3b46b"
]
]
},
{
"id": "e92bb1ca62f3b46b",
"type": "debug",
"z": "cbf7f47c.caccc8",
"name": "",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "false",
"statusVal": "",
"statusType": "auto",
"x": 3860,
"y": 4720,
"wires": []
},
{
"id": "71d609dcf5757665",
"type": "inject",
"z": "cbf7f47c.caccc8",
"name": "",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "",
"payloadType": "date",
"x": 3480,
"y": 4720,
"wires": [
[
"a48e4c1ee433cb0e"
]
]
}
]
What is the reason that concat does not add 1,1 to the empty array named "value"?