# Ok, My inexperience with Javascript is showing!

**URL:** <https://discourse.nodered.org/t/ok-my-inexperience-with-javascript-is-showing/29249>\
**Category:** General\
**Created:** [30 June 2020 17:00 UTC](https://discourse.nodered.org/t/ok-my-inexperience-with-javascript-is-showing/29249 "2020-06-30T17:00:20Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nodi.Rubrum](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/nodi.rubrum/32/107482_2.png) [@Nodi.Rubrum](https://discourse.nodered.org/u/Nodi.Rubrum)\
**Post date:** [30 June 2020 17:00 UTC](https://discourse.nodered.org/t/ok-my-inexperience-with-javascript-is-showing/29249/1 "2020-06-30T17:00:20Z")

</div>

If have a payload that has the following:

```auto
array[1]
0: object
Index: 1

```

How the heck do I get to the value of the index key? This is a javascript array, with one element, that happens to be a javascript object? Or I am misunderstanding this?

If someone bumps me to nodejs forum... ok. 🙂

---

<div class="post-metadata">

**Author:** ![ristomatti](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ristomatti/32/5857_2.png) [@ristomatti](https://discourse.nodered.org/u/ristomatti)\
**Post date:** [30 June 2020 17:04 UTC](https://discourse.nodered.org/t/ok-my-inexperience-with-javascript-is-showing/29249/2 "2020-06-30T17:04:25Z")

</div>

`msg.payload[0].Index`?

---

<div class="post-metadata">

**Author:** ![Nodi.Rubrum](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/nodi.rubrum/32/107482_2.png) [@Nodi.Rubrum](https://discourse.nodered.org/u/Nodi.Rubrum)\
**Post date:** [30 June 2020 17:12 UTC](https://discourse.nodered.org/t/ok-my-inexperience-with-javascript-is-showing/29249/3 "2020-06-30T17:12:27Z")

</div>

Swear I have tried that... All I get is undefined.

Debug...

```auto
6/30/2020, 10:09:04 AMnode: QueryINSERT INTO Ambient(`Time`, `Altitude`, `Sensor`, `Temperature`, `Pressure`, `Humidity`, `Host`) VALUES (1593466209.1504729, null, 0, 32.10307469291219, null, 29.829861905851836, 0); : msg.payload : string[75]
"1593466209.1504729, null, 0, 32.10307469291219, null, 29.829861905851836, 0"
6/30/2020, 10:09:04 AMnode: RawINSERT INTO Ambient(`Time`, `Altitude`, `Sensor`, `Temperature`, `Pressure`, `Humidity`, `Host`) VALUES (1593466209.1504729, null, 0, 32.10307469291219, null, 29.829861905851836, 0); : msg.payload : Object
{ fieldCount: 0, affectedRows: 1, insertId: 25, serverStatus: 2, warningCount: 0 … }
6/30/2020, 10:09:04 AMnode: Insert Ambient DataINSERT INTO Ambient(`Time`, `Altitude`, `Sensor`, `Temperature`, `Pressure`, `Humidity`, `Host`) VALUES (1593466209.1504729, null, 0, 32.10307469291219, null, 29.829861905851836, 0); : msg : undefined
undefined

```

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [30 June 2020 17:14 UTC](https://discourse.nodered.org/t/ok-my-inexperience-with-javascript-is-showing/29249/4 "2020-06-30T17:14:28Z")

</div>

Hi. You can save yourself a lot of trouble if you use the copy path button that appears when you hover over a debug output.

You learn this and much more from this Playlist: [Node-RED Essentials](https://www.youtube.com/playlist?list=PLyNBB9VCLmo1hyO-4fIZ08gqFcXBkHy-6). It is by the developers of node-red. They're nice & short and to the point. You will understand a whole lot more in less than an hour.

---

<div class="post-metadata">

**Author:** ![Nodi.Rubrum](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/nodi.rubrum/32/107482_2.png) [@Nodi.Rubrum](https://discourse.nodered.org/u/Nodi.Rubrum)\
**Post date:** [30 June 2020 17:15 UTC](https://discourse.nodered.org/t/ok-my-inexperience-with-javascript-is-showing/29249/5 "2020-06-30T17:15:23Z")

</div>

Ah, Thanks!

---

<div class="post-metadata">

**Author:** ![afelix](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/afelix/32/9743_2.png) [@afelix](https://discourse.nodered.org/u/afelix)\
**Post date:** [30 June 2020 17:37 UTC](https://discourse.nodered.org/t/ok-my-inexperience-with-javascript-is-showing/29249/6 "2020-06-30T17:37:25Z")

</div>

Or, if you're more for the reading documentation based approach, this document from the Node-RED docs is worth a read: [Working with Messages](https://nodered.org/docs/user-guide/messages)

---

<div class="post-metadata">

**Author:** ![Nodi.Rubrum](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/nodi.rubrum/32/107482_2.png) [@Nodi.Rubrum](https://discourse.nodered.org/u/Nodi.Rubrum)\
**Post date:** [30 June 2020 17:42 UTC](https://discourse.nodered.org/t/ok-my-inexperience-with-javascript-is-showing/29249/7 "2020-06-30T17:42:23Z")

</div>

I have watched some, read most. One of the reasons I have gone from zero to now, never having worked with Node Red before about 2 weeks ago, or touched Javascript... many other languages just not js based stuff. But I digress... I figured out why it was not working, my SQL statement was NOT returning Index field query correctly... jeez. Such a rookie mistake.

---

<div class="post-metadata">

**Author:** ![Nodi.Rubrum](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/nodi.rubrum/32/107482_2.png) [@Nodi.Rubrum](https://discourse.nodered.org/u/Nodi.Rubrum)\
**Post date:** [30 June 2020 20:25 UTC](https://discourse.nodered.org/t/ok-my-inexperience-with-javascript-is-showing/29249/8 "2020-06-30T20:25:49Z")

</div>

Curious... there is a flow.keys() function but no flow.values() function? That seems a bit odd.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [30 June 2020 21:02 UTC](https://discourse.nodered.org/t/ok-my-inexperience-with-javascript-is-showing/29249/9 "2020-06-30T21:02:00Z")

</div>

flow.keys gives you the keys, which you can use to get the values. A javascript object does not have a method to get just the values as far as I know. The values would be meaningless without the associated keys as you wouldn't know which was which.

---

<div class="post-metadata">

**Author:** ![ristomatti](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ristomatti/32/5857_2.png) [@ristomatti](https://discourse.nodered.org/u/ristomatti)\
**Post date:** [30 June 2020 21:19 UTC](https://discourse.nodered.org/t/ok-my-inexperience-with-javascript-is-showing/29249/10 "2020-06-30T21:19:52Z")

</div>

You'll likely find the reason from this feature request I wrote (spoiler - it didn't get support): [Support destructuring expression for context properties](https://discourse.nodered.org/t/support-destructuring-expression-for-context-properties/27831)

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [14 July 2020 21:19 UTC](https://discourse.nodered.org/t/ok-my-inexperience-with-javascript-is-showing/29249/11 "2020-07-14T21:19:52Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
