javascript数据类型和函数的简单的使用

js变量和数据类型

<!doctype html>
<html>
 <head>
  <title>Document</title>
 </head>
 <body>
  <script>
  var a=10;//定义变量
  var b=" abc ";//定义字符串
  var c=[" hello ","world "];//定义数组
  var d=true;//定义bool
  document.write(a);
  document.write(b);
  document.write(c);
  document.write(d);
  </script>
 </body>
</html>

js函数

<html>
<head>
<title>a</title>
</head>
<body>
<script>
function demo(){
var a=10;
alert("登陆失败");
}
//demo();  //script中调用函数
</script>
<button onclick="demo();">按钮</button>  //通过button调用函数
</body>
</html>

require.js作用:
  (1)实现js文件的异步加载,避免网页失去响应;
  (2)管理模块之间的依赖性,便于代码的编写和维护。
用法:http://www.ruanyifeng.com/blog/2012/11/require_js.html


原文地址:https://www.cnblogs.com/wangxueliang/p/9346518.html