Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the differences between lua and javascript

2025-02-22 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly shows you the difference between lua and javascript, the content is easy to understand, clear, hope to help you solve your doubts, the following let the editor to take you to study and learn the "what is the difference between lua and javascript" this article.

Differences: 1, JavaScript comment code is "/ /", lua comment code is "-"; 2, JavaScript uses val to declare that global variables do not exist local variables, lua does not need to be directly located as a global variable, local declaration is a local variable.

The operating environment of this tutorial: windows10 system, javascript1.8.5 version, Dell G3 computer.

What is the difference between lua and javascript

Difference comparison between Lua and Javascript

Js Scheme of Lua Simulator

1. Grammar level simulation

Language differences between lua and js

1.1 comment

Js is / /, lua is -.

1.2 variables

Js uses val to declare that global variables do not exist local variables, lua does not need to be directly located is a global variable, local declaration is a local variable.

1.3 operator

Js

+-* /% +--

= +-= * /% =

Support string +

Txt1 = "what a very"

Txt2 = "nice day"

Txt3 = txt1 "" + txt2

Print txt3 output as "what a very nice day".

Rules:

Add the number to the string and the result will be a string.

Lua

Binary: +-* / ^%

One yuan:-(minus sign)

The lua string is concatenated to..

For example, "Hello".. "World" is spliced into Hello World

1.4 Relational operator

Js relational operator

= (congruent)! = >

< >

= (not equal to)

1.5 logical operator

Js

& & | |!

Lua

And or not

1.6 If... Else statement

Js class c

If else

Lua

If then else

If then

Elseif then

Else

End

There must be end.

1.7 Switch statement

Lua does not support Switch statements

1.8 message box

Js

Warning box alert ("text")

Confirm box prompt ("text", "default")

Lua

Extended support for warning and confirmation boxes

1.9 function

Js

Function function name (parameter) {code.}

Js with {} class c

Lua

Function function name (argument) end

Lua class vb script

2.0 For Loop

Js: class c

For (iSuppli)

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report