1
I have a array in the language Lua, and wanted to pass its elements to a array Javascript. Example of array Moon:
tabela_y = {0, 1, 2}
In PHP there is implode, I do not know if it is possible in Lua.
1
I have a array in the language Lua, and wanted to pass its elements to a array Javascript. Example of array Moon:
tabela_y = {0, 1, 2}
In PHP there is implode, I do not know if it is possible in Lua.
4
There is the function concat()
who does this:
tabela_y = {0, 1, 2}
print(table.concat(tabela_y, ","))
Behold working in the ideone. And in the repl it.. Also put on the Github for future reference.
I wanted to pass these table values to a javascript array.
I was already in aarray. If you need more than that depends on what you’re doing. You should already know that there is no Moon stuff going on for JS, you should put together a page by putting what you want.
Browser other questions tagged javascript lua
You are not signed in. Login or sign up in order to post.
You want to transform the array in string separated by commas, this is it?
– Maniero
Yes, and then rewind this string to an array.
– akm
Instead of doing this by hand, an alternative you could take a look at is to use an existing JSON serialization library. This way you protect yourself against Javascript Injection (XSS) attacks if your table contains user strings (rather than just numbers)
– hugomg
The answer solved the problem? You can accept it?
– Maniero