@@ -97,9 +97,9 @@
// console.log(obj[0],obj[1]);
// }
- for(let [index,val] of arr.entries()){
- console.log(index,val);
- }
+ // for(let [index,val] of arr.entries()){
+ // console.log(index,val);
+ // }
</script>
@@ -96,8 +96,8 @@
// foo.apply(obj,["world","你好"])
// bind 它是将函数的this指向修改后返回一个函数,并不是立即执行。参数部分跟call方法一样
- var foo2 = foo.bind(obj,"hello","你好")
- foo2();
+ // var foo2 = foo.bind(obj,"hello","你好")
+ // foo2();
</body>
</html>
@@ -44,14 +44,14 @@
// console.log(boo.constructor == Boolean);
// 方法四
- console.log( Object.prototype.toString.call(und) );
- console.log( Object.prototype.toString.call(nu) );
- console.log( Object.prototype.toString.call(str) );
- console.log( Object.prototype.toString.call(num) );
- console.log( Object.prototype.toString.call(foo) );
- console.log( Object.prototype.toString.call(boo) );
- console.log( Object.prototype.toString.call(arr) );
- console.log( Object.prototype.toString.call(obj) );
+ // console.log( Object.prototype.toString.call(und) );
+ // console.log( Object.prototype.toString.call(nu) );
+ // console.log( Object.prototype.toString.call(str) );
+ // console.log( Object.prototype.toString.call(num) );
+ // console.log( Object.prototype.toString.call(foo) );
+ // console.log( Object.prototype.toString.call(boo) );
+ // console.log( Object.prototype.toString.call(arr) );
+ // console.log( Object.prototype.toString.call(obj) );
@@ -34,15 +34,15 @@
// console.log(s4.size);
- let obj = {
- b:2
- let ws = new WeakSet();
- ws.add({a:1});
- ws.add(obj);
- // ws.add(1);
- console.log(ws)
+ // let obj = {
+ // b:2
+ // let ws = new WeakSet();
+ // ws.add({a:1});
+ // ws.add(obj);
+ // // ws.add(1);
+ // console.log(ws)
@@ -0,0 +1,20 @@
+<!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 a = 10;
+ setTimeout(function(){
+ console.log(a)
+ }, 1000);
+ a++;
+ </script>
+</body>
+</html>
@@ -0,0 +1,37 @@
+ function ajaxFun(url,foo) {
+ // 第一步 创建XMLHttpRequest 对象;
+ var xmlh = new XMLHttpRequest();
+ // 第二步 发送请求
+ xmlh.open("GET", url, true);
+ xmlh.send();
+ // 第三步 处理请求结果
+ xmlh.onreadystatechange = function () {
+ if (xmlh.readyState == 4 && xmlh.status == 200) {
+ var resObj = JSON.parse(xmlh.responseText)
+ // console.log(resObj)
+ // return resObj;
+ foo(resObj)
+ }
+ // console.log(ajaxFun("./data/data1.json"));
+ ajaxFun("./data/data1.json",function(res){
+ console.log(res);
+ })
@@ -79,10 +79,10 @@
// var [a,b] = [b,a];
// console.log(a,b);
- var xiaomiPhoneJson = '{"title":"小米手机","price":4999,"pic":"xxxx.png"}';
- var jsonObj = JSON.parse(xiaomiPhoneJson);
- var {title} = jsonObj;
- console.log(title);
+ // var xiaomiPhoneJson = '{"title":"小米手机","price":4999,"pic":"xxxx.png"}';
+ // var jsonObj = JSON.parse(xiaomiPhoneJson);
+ // var {title} = jsonObj;
+ // console.log(title);
@@ -16,12 +16,12 @@
<li>5</li>
</ul>
<script>
- var aLi = document.getElementsByTagName("li");
- for(let i=0;i<aLi.length;i++){
- aLi[i].onclick = function(){
- console.log(i);
+ // var aLi = document.getElementsByTagName("li");
+ // for(let i=0;i<aLi.length;i++){
+ // aLi[i].onclick = function(){
+ // console.log(i);
// // 闭包 函数内部嵌套一个函数 内部函数可以调用外部函数的局部变量,这个变量不会消失 一直保存在内存当中
// var aLi = document.getElementsByTagName("li");
// for (var i = 0; i < aLi.length; i++) {
@@ -0,0 +1,16 @@
+function ajaxFun(url,foo) {
+}
@@ -0,0 +1,38 @@
+{
+ "code": 101,
+ "message": "展示职位成功",
+ "data": [
+ {
+ "jrid": 59,
+ "levelname": "支行副行长"
+ },
+ "jrid": 60,
+ "levelname": "业务主管"
+ "jrid": 61,
+ "levelname": "业务副主管"
+ "jrid": 62,
+ "levelname": "高级柜员"
+ "jrid": 63,
+ "levelname": "中级柜员"
+ "jrid": 64,
+ "levelname": "普通柜员"
+ "jrid": 65,
+ "levelname": "实习生"
+ "jrid": 78,
+ "levelname": "水质监测员"
+ ]
+ "message": "展示姓名成功",
+ "userName":"小张"
+ "userName":"小李"
+ "userName":"小王"
+ "userName":"小赵"
+ "userName":"小孙"
+ "userName":"小周"
+ "userName":"小陈"
+ "userName":"小魏"
@@ -13,7 +13,7 @@
// 第一题
var n = 13;
function fn(n) {
- alert(n);
+ alert(n);//
n = 14;
alert(n);
}
@@ -115,7 +115,7 @@
var foo2 = foo.bind2(obj);
- foo2()//hello
+ foo2()
@@ -176,18 +176,18 @@
// foo2()
//9、补全下列代码
- var o = { prop: 'loveCoding' };
-
- function independent() {
- return this.prop;
- //在此补全代码
- // o.f = independent.bind(o);
- o.f = function(){
- return independent.call(o)
- console.log(o.f()); // loveCoding
+ // var o = { prop: 'loveCoding' };
+ // function independent() {
+ // return this.prop;
+ // //在此补全代码
+ // // o.f = independent.bind(o);
+ // o.f = function(){
+ // return independent.call(o)
+ // console.log(o.f()); // loveCoding
@@ -8,7 +8,61 @@
<body>
let arr = [ 1,2,3,'a',4,5,3,4,5,'a' ];
+ // 方法一 双循环
+ // function unique(arr){
+ // for(var i=0;i<arr.length;i++){
+ // for(var j=i+1;j<arr.length;j++){
+ // if(arr[i] == arr[j]){
+ // arr.splice(j,1)
+ // j--;
+ // return arr;
+ // console.log(unique(arr));
+ // 方法二 :indexOf 和 新数组
+ // var newArr = [];
+ // if(arr.indexOf(arr[i]) == i){
+ // newArr.push(arr[i])
+ // return newArr;
+ // 方法三 对象中key值不能重复
+ // var obj = {
+ // a:"hell",
+ // b:"world",
+ // a:1
+ // console.log(obj);
+ // var obj = {};
+ // if(arr[i] in obj){
+ // obj[arr[i]]++;
+ // }else{
+ // obj[arr[i]] = 1
+ // // return obj;
+ // return Object.keys(obj);
+ // 方法四 es6
+ // return Array.from(new Set(arr));
+ <script src="./ajax.js"></script>