# \#function-node

**URL:** https://forums.losant.com/tag/function-node/47.md

[Latest](https://forums.losant.com/latest.md) · [Categories](https://forums.losant.com/categories.md) · [Tags](https://forums.losant.com/tags.md)

---

## [How to access a global variable from the JS function?](https://forums.losant.com/t/how-to-access-a-global-variable-from-the-js-function/5162)

<div class="topic-metadata">

**Author:** [@Paolo\_Proxy](https://forums.losant.com/u/Paolo_Proxy)\
**Replies:** 2\
**Last updated:** [July 21, 2023, 9:55am UTC](https://forums.losant.com/t/how-to-access-a-global-variable-from-the-js-function/5162 "2023-07-21T09:55:30Z")

</div>

Hi there, is there some sort of special variable defined in the JS scope that I can use to grab the global variable?

---

## [Why do I get different Javascript errors in Chrome's interpreter vs. Losant Function node?](https://forums.losant.com/t/why-do-i-get-different-javascript-errors-in-chromes-interpreter-vs-losant-function-node/2296)

<div class="topic-metadata">

**Author:** [@Alexander\_Farley](https://forums.losant.com/u/Alexander_Farley)\
**Replies:** 3\
**Last updated:** [October 18, 2019, 7:06pm UTC](https://forums.losant.com/t/why-do-i-get-different-javascript-errors-in-chromes-interpreter-vs-losant-function-node/2296 "2019-10-18T19:06:05Z")

</div>

I had this code in a Function node: var test; test.start\_time\_ms = 100; This node returns an error: “Cannot set property ‘start\_time\_ms’ of undefined.” If I switch to this, then the error goes away: var test = {}; te…

---

## [Converting bit string to multiple boolean device attributes](https://forums.losant.com/t/converting-bit-string-to-multiple-boolean-device-attributes/1708)

<div class="topic-metadata">

**Author:** [@Lars\_Andersson](https://forums.losant.com/u/Lars_Andersson)\
**Replies:** 2\
**Last updated:** [April 10, 2019, 4:33pm UTC](https://forums.losant.com/t/converting-bit-string-to-multiple-boolean-device-attributes/1708 "2019-04-10T16:33:29Z")

</div>

I was able to convert a integer to a integer string such as 1001010. Now I want each of those binary positions to translate to individual boolean bit values to use as device attributes. Any suggestions?

---

## [Payload variable in function](https://forums.losant.com/t/payload-variable-in-function/1707)

<div class="topic-metadata">

**Author:** [@Lars\_Andersson](https://forums.losant.com/u/Lars_Andersson)\
**Replies:** 2\
**Last updated:** [April 10, 2019, 3:31pm UTC](https://forums.losant.com/t/payload-variable-in-function/1707 "2019-04-10T15:31:31Z")

</div>

I’m trying to use payload variable payload.data.\[01\_Status\] as below, but it doesn;t like the square brackets. I have tried without them but it doesn’t like that either. payload.data.state\_bits = intToUint(payload.dat…

---

## [Convert array to string](https://forums.losant.com/t/convert-array-to-string/1525)

<div class="topic-metadata">

**Author:** [@paul\_wareham](https://forums.losant.com/u/paul_wareham)\
**Replies:** 1\
**Last updated:** [February 11, 2019, 10:23pm UTC](https://forums.losant.com/t/convert-array-to-string/1525 "2019-02-11T22:23:11Z")

</div>

Hi Folks, What is the easiest way to convert an array on a payload into a string of the array values with a separating character between each value? Thanks Paul
