Skip to content

Commit

Permalink
20180626
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangyue0503 committed Jun 26, 2018
1 parent a163928 commit 9e12fbc
Show file tree
Hide file tree
Showing 31 changed files with 465 additions and 0 deletions.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
21 changes: 21 additions & 0 deletions es6/jses6xl/2/bind.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
<script>
setTimeout.call(window,()=>{
alert.call(window,1);
},1000);
// alert.call(window,1);
// function show(){
// console.log(this+10);
// }
// show.call(1);
</script>
</body>
</html>
18 changes: 18 additions & 0 deletions es6/jses6xl/2/bind2.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
<script>
function show(x,y,z){
// alert(this+x);
console.log(x,y,z);
}
show.bind(1,2)(1);
</script>
</body>
</html>
27 changes: 27 additions & 0 deletions es6/jses6xl/2/es6面向对象.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
<script>
class a {
constructor(x,y,z){
console.log(x,y,z);
// this.x = 10;
// console.log(this.x);
}
ffff(){
alert(1);
}
}

new a(11,[1,2,3],{a:50}).ffff();


</script>
</body>
</html>
24 changes: 24 additions & 0 deletions es6/jses6xl/2/toString.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
<script>
var json = {a:20,b:30};
console.log(String.prototype.substring.call(json,2));

var a = ['asdasd'];

console.log(String.prototype.split.call(a));
// console.log(Object.prototype.toString.call({}));
function show(){
console.log(Object.prototype.toString.call(arguments));
}
show();
</script>
</body>
</html>
23 changes: 23 additions & 0 deletions es6/jses6xl/2/toString2.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
<script>
function show(){
// console.log(1);
}
show.prototype.a = function(){
alert(1);
}
var c = new show();
c.a();
// var c = show;
// console.log(c.prototype);
</script>
</body>
</html>
67 changes: 67 additions & 0 deletions es6/jses6xl/2/xuanxiangka-jquery.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<style>
input.active {
background: red;
}

#box>div {
width: 200px;
height: 200px;
background: #ccc;
display: none;
}

#box>div:first-of-type {
display: block;
}
</style>
</head>


<body>
<div id='div1'></div>
<div class='div1'></div>
<div class='div1'></div>
<script>
class jquery {
constructor(obj) {
this.obj = obj;
this.allNode = [];
switch (this.obj.charAt(0)) {
case '#':
this.allNode.push(document.getElementById(this.obj.substring(1)));
console.log(this.allNode);
break;
case '.':
this.myObj = document.getElementsByClassName(this.obj.substring(1));
for(let i=0;i<this.myObj.length;i++){
this.allNode.push(this.myObj[i]);
}
console.log(this.allNode);
break;
}
}

addClass(className){
for(let i=0;i<this.allNode.length;i++){
this.allNode[i].classList.add(className);
}
}
}

function $(obj) {
return new jquery(obj);
}
$('#div1');
$('.div1').addClass('a');
</script>
</body>

</html>
95 changes: 95 additions & 0 deletions es6/jses6xl/2/xuanxiangka.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<style>
input.active {
background: red;
}

#box>div {
width: 200px;
height: 200px;
background: #ccc;
display: none;
}

#box>div:first-of-type {
display: block;
}
</style>
</head>


<body>
<div id="box">
<input type="button" class="active" value="1">
<input type="button" value="2">
<input type="button" value="3">
<div>aaa</div>
<div>bbb</div>
<div>ccc</div>
</div>
<div id="ccc">
<input type="button" class="active" value="1">
<input type="button" value="2">
<div>bbb</div>
<div>ccc</div>
</div>
<script>
class tab {
constructor(x) {
this.node = document.getElementById(x);
this.allIpt = this.node.getElementsByTagName('input');
this.allDiv = this.node.getElementsByTagName('div');
this.init();
this.index = 0;
}
init() {
for (let i = 0; i < this.allIpt.length; i++) {
this.allIpt[i].onclick = function () {
this.hide();
this.show(i);
}.bind(this);
}
}
hide() {
for (let i = 0; i < this.allIpt.length; i++) {
this.allIpt[i].className = '';
this.allDiv[i].style.display = 'none';
}
}
show(index) {
this.allDiv[index].style.display = 'block';
this.allIpt[index].className = 'active';
}

}

// new tab('box');

class autoTab extends tab{
constructor(x){
super(x);
}
autoPlay(){
// var _this = this;
setInterval(()=>{
console.log(this);
this.index++;
if(this.index == this.allIpt.length)this.index = 0;
this.hide();
this.show(this.index);
},1000);
}
}
new tab('box');
new autoTab('ccc').autoPlay();
</script>
</body>

</html>
45 changes: 45 additions & 0 deletions es6/jses6xl/2/块级作用域.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<style>
.active{
background:red;
}
</style>
</head>
<body>
<input type="button" value="1">
<input type="button" value="2">
<input type="button" value="3">
<script>
let allInput = document.getElementsByTagName('input');

for(let i =0;i<allInput.length;i++){
//块级作用域
allInput[i].onclick = function(){
for(var j = 0;j<allInput.length;j++){
allInput[j].className = '';
}
allInput[i].className = 'active';
alert(i);
}

// (function(x){
// // console.log(x);
// allInput[x].onclick = function(){
// alert(x);
// }
// })(i);

// allInput[i].onclick = function(){
// alert(i);
// }
}

</script>
</body>
</html>
20 changes: 20 additions & 0 deletions es6/jses6xl/2/结构赋值.html
Original file line number Diff line number Diff line change
@@ -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">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
<script>
// var a = 10;
// var b = 20;
// var c = 30;

let [a,[b,c],d] = [10,[20,40],30];
console.log(a,b,c,d);

</script>
</body>
</html>
19 changes: 19 additions & 0 deletions es6/jses6xl/2/结构赋值2.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
<script>
var json = {'a':20,'b':30};

let {a,b} = json;
let {c,d} = json;
console.log(a,b,c,d);

</script>
</body>
</html>
Loading

0 comments on commit 9e12fbc

Please sign in to comment.