I need to pass an array of string values to a string literal in the following way
Code :
var arr = ['1','2556','3','4','5'];
...
...
var output = `
<scr`+`ipt>
window.stringArray = [`+ arr +`]
</scr`+`ipt>
`
Output :
<script>
window.stringArray = [1,2556,3,4,5]
</script>
Desired Output:
<script>
window.stringArray = ['1','2556','3','4','5']
</script>
I attempted to avoid converting the arrays into strings and instead include them inside the multiline string, but the values are too large for integer handling and get truncated e.g. [888555985744859665555] becomes [888555985744859665500] causing memory issues, so it is preferable to use strings! I also tried using the map function within the inline string like this
`[`+ array.map(String) +`]`
I am unable to add more lines to the existing output string mentioned above, any modifications should be implemented within the one line or added above it!