Lua array/table for Javascript

Asked

Viewed 191 times

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.

  • You want to transform the array in string separated by commas, this is it?

  • Yes, and then rewind this string to an array.

  • 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)

  • The answer solved the problem? You can accept it?

1 answer

4

  • 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

You are not signed in. Login or sign up in order to post.