173、[].forEach、$.each和angular.forEach用法示例

<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <title></title>
</head>

<body>
本代码不能运行
</body>

</html>
<script>
  //1111111111111111111111111111111111111
  [3, 3, 3].forEach(function (a, b, c, d) {
    //3 0 [ 3, 3, 3, 3, 3 ] undefined
    console.log(a, b, c, d)
  })
  //2222222222222222222222222222222222222
  $.each([3, 3, 3, 3], function (a, b, c) {
    console.log(a, b, c)
    //0 3 undefined

  })
  $.each({ a: 'b' }, function (a, b) {
    console.log(a, b)
    //a,b
  });
  //3333333333333333333333333333333333333
  angular.forEach([3, 3, 3], function (a, b, c, d) {
    console.log(a, b, c, d)
    //3 0 Array(6) undefined
  });
  angular.forEach({ a: 'b' }, function (a, b) {
    console.log(a, b)
    //b,a
  });
</script>

<!-- <!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>angular</title>
  <script src="https://cdn.bootcss.com/jquery/1.9.1/jquery.js"></script>
</head>
<body>
</body>
</html>
<script>
</script> --></html>

<!-- <!DOCTYPE html>
<html lang="en" ng-app="myModel">

<head>
  <meta charset="UTF-8">
  <title>select</title>
  <script src="https://cdn.bootcss.com/echarts/3.7.1/echarts.js"></script>
  <script src="https://cdn.bootcss.com/jquery/1.9.1/jquery.js"></script>
  <script src="https://cdn.bootcss.com/angular.js/1.6.2/angular.js"></script>
</head>

<body>
  <div ng-controller="firstCtrl">
    <div style="width:100%;display:flex;">
      <div style="width:50%;display:flex;flex-direction:column;" id="left">
      </div>
      <div style="width:50%;display:flex;flex-direction:column;" id="right">
      </div>
    </div>
  </div>
</body>

</html>
<script>
  var app = angular.module('myModel', []);
  app.controller('firstCtrl', function ($scope) {

  }); 
</script>
 -->

猜你喜欢

转载自www.cnblogs.com/gushixianqiancheng/p/12166831.html
今日推荐