|
@@ -0,0 +1,75 @@
|
|
|
+<!DOCTYPE html>
|
|
|
+<html lang="en">
|
|
|
+<head>
|
|
|
+ <meta charset="UTF-8">
|
|
|
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
|
+ <title>Document</title>
|
|
|
+</head>
|
|
|
+<body>
|
|
|
+ <script>
|
|
|
+ // var arr = [1,2,3,4,5];
|
|
|
+
|
|
|
+ // var isInclude = false;
|
|
|
+ // for(var i =0;i<arr.length;i++){
|
|
|
+ // if(arr[i] == 3){
|
|
|
+ // isInclude = true;
|
|
|
+ // break;
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // console.log(isInclude)
|
|
|
+
|
|
|
+ // console.log(arr.includes(3))
|
|
|
+
|
|
|
+
|
|
|
+ // function 函数声明关键字
|
|
|
+ // foo 代表函数名称
|
|
|
+ // ()用作接受参数
|
|
|
+ // {} 方法体
|
|
|
+ // function foo(){
|
|
|
+
|
|
|
+ // }
|
|
|
+
|
|
|
+ // 函数定义及调用
|
|
|
+ // function foo(){
|
|
|
+ // console.log("hello");
|
|
|
+ // }
|
|
|
+
|
|
|
+ // foo();
|
|
|
+
|
|
|
+ // 函数定义及传参
|
|
|
+ // function foo(str){
|
|
|
+ // console.log(str);
|
|
|
+ // }
|
|
|
+ // // foo("hello world");
|
|
|
+ // var str1 = "hello world";
|
|
|
+ // foo(str1);
|
|
|
+
|
|
|
+ // 多参数函数
|
|
|
+ // function addFun(a,b){
|
|
|
+ // console.log(a+b);
|
|
|
+ // }
|
|
|
+ // addFun(1,2);
|
|
|
+
|
|
|
+ // 带返回值的函数
|
|
|
+ // function foo(){
|
|
|
+ // // console.log("123");
|
|
|
+ // return "loveCoding";
|
|
|
+ // }
|
|
|
+ // var str = foo();
|
|
|
+ // console.log(str);
|
|
|
+
|
|
|
+ // return 会结束函数的执行 后边的语句将不会执行
|
|
|
+ // function foo(){
|
|
|
+ // return "返回值";
|
|
|
+ // console.log("hello");
|
|
|
+ // }
|
|
|
+ // foo();
|
|
|
+
|
|
|
+
|
|
|
+ var foo = function(){
|
|
|
+ console.log("hello");
|
|
|
+ }
|
|
|
+ foo();
|
|
|
+ </script>
|
|
|
+</body>
|
|
|
+</html>
|