lua.vm.js
REPL
Lua REPL(交互式解释器)
这是一个 Lua 语言的
REPL
. 点击按钮执行编辑区域中的代码. 你也可以编写你自己的lua代码并运行.
print('hello' .. ' ' .. 'world!') -- This is Lua! print(js.global:eval('[0,1,2,3,4,5][3]')) -- Run JS from Lua -- Interact with the page using Lua local screen = js.global.screen print("you haz " .. (screen.width*screen.height) .. " pixels") local window = js.global -- global object in JS is the window window:alert("hello from lua!") window:setTimeout(function() print('hello from lua callback') end, 2500) local document = js.global.document print("this window has title '" .. document.title .. "'") -- call constructors (global, or as properties of other objects) print("i made an ArrayBuffer of size " .. js.new(js.global.ArrayBuffer, 20).byteLength) -- print("i made an ArrayBuffer of size " .. js.global.ArrayBuffer:new(20).byteLength) print("time iz " .. js.global.Date.now()) -- call with no arguments print('done!')
output
Execute »