是的,将所有 JavaScript 声明放在顶部是一个很好的做法。让我们看一个例子 -
<html> <head> <title>JavaScript String match() Method</title> </head> <body> <script> // all the variables declared at top var str, re, found; str = "For more information, see Chapter 3.4.5.1"; re = /(chapter \d+(\.\d)*)/i; found = str.match( re ); document.write(found ); </script> </body> </html>
以下是有效的原因 -
以上就是在JavaScript中,将所有声明放在顶部是一种好的做法吗?的详细内容,更多请关注php中文网其它相关文章!
已抢65117个
抢已抢28527个
抢已抢15415个
抢已抢7730个
抢已抢9631个
抢已抢19609个
抢