Skip to content

Commit a0cbb68

Browse files
author
lijiabin01
committed
JSHint inject
1 parent ac55e92 commit a0cbb68

3 files changed

Lines changed: 33 additions & 15 deletions

File tree

JavaScript_1/深入浅出/test2.js

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
/* jshint esversion: 6 */
2+
/* jshint expr: true */
3+
14
// window.onload = function(){
25
// var obj = {x: 4};
36
// console.log(obj.x);
@@ -7,11 +10,12 @@ var obj = {x: 431};
710
console.log(obj.x);
811

912
// .instanceof运算符: 此运算符可以判断一个变量是否是某个对象(类)的实例,返回值是布尔类型的
10-
var str = new String("antzone");
13+
// var str = new String("antzone");
14+
var str = String("antzone");
1115
console.log(str instanceof String);
1216

1317
//typeof运算符:此运算符可以返回一个字符串,用语说明元算数的类型
14-
var str = new String("antzone");
18+
var str = String("antzone");
1519
var strTwo = "antzone";
1620
console.log(typeof str);
1721
console.log(typeof strTwo);
@@ -26,7 +30,8 @@ console.log(obj2);
2630

2731
// 属性 get set 方法
2832
// delete 删除属性
29-
var cat = new Object();
33+
// var cat = new Object();
34+
var cat = {};
3035
cat.legs = 4;
3136
cat.name = "kitty";
3237
console.log(cat);
@@ -36,7 +41,7 @@ if (cat.hasOwnProperty('legs')) {
3641
var man = {
3742
age: 28,
3843
weibo: '@Bosd'
39-
}
44+
};
4045
console.log(typeof cat);
4146
console.log(typeof man);
4247

@@ -49,14 +54,15 @@ function Person() {
4954
Person.prototype.name = 'Kevin';
5055
var person1 = new Person();
5156
var person2 = new Person();
52-
console.log(person1.name) // Kevin
53-
console.log(person2.name) // Kevin
57+
console.log(person1.name); // Kevin
58+
console.log(person2.name); // Kevin
5459

5560
// --
5661
function People() {
5762
}
5863
var people = new People();
59-
console.log("prototype and __proto__ test:" + (people.__proto__ === People.prototype)); // true
64+
// console.log("prototype and __proto__ test:" + (people.__proto__ === People.prototype)); // true
65+
console.log("prototype and __proto__ test:" + (Object.getPrototypeOf(people) === People.prototype)); // true
6066
// --
6167

6268
// 对象标签、序列化
@@ -89,12 +95,12 @@ console.log("Person class:" + typeof Person);
8995

9096
Person.prototype.hi = function(){
9197
console.log("Hi my name is" + this.name + "i am" + this.age + "years old now");
92-
}
98+
};
9399
Person.prototype.LEGS_NUM = 2;
94100
Person.prototype.ARMS_NUM = 2;
95101
Person.prototype.walk = function(){
96102
console.log(this.name + "is walking");
97-
}
103+
};
98104

99105
function Student(name, age, className) {
100106
// call调用父类
@@ -110,11 +116,11 @@ Student.prototype.constructor = Student;
110116

111117
Student.prototype.hi = function(){
112118
console.log("Hi my name is" + this.name + "i am" + this.age + "years old now" + "and from" + this.className);
113-
}
119+
};
114120

115121
Student.prototype.learn = function(subject){
116122
console.log("Hi my name is" + this.name + "is learning" + subject + "at" + this.className + ".");
117-
}
123+
};
118124

119125
var bosn = new Student("Bosn", 29, "Class3,Grade 2");
120126
console.log("new obj type" + typeof bosn);
@@ -140,7 +146,7 @@ class ColorPoint extends Point {
140146
}
141147

142148
let cp = new ColorPoint(25, 8, 'green');
143-
cp instanceof ColorPoint // true
144-
cp instanceof Point // true
149+
cp instanceof ColorPoint; // true
150+
cp instanceof Point; // true
145151
let cp2 = new Point(24, 56);
146152

JavaScript_1/深入浅出/test3.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ var arr5 = [1, 2, 3];
3232
arr.map(function(x){
3333
return x + 10;
3434
});
35+
arr.filter(function(x){
36+
return x > 1;
37+
});
3538

3639
// 数组过滤filter
3740
// 数组判断every some
@@ -75,14 +78,20 @@ bar.call(7);
7578

7679
// 闭包 可以封装一些复杂的函数逻辑,可以访问函数里面的变量
7780
// 滥用闭包会导致性能和空间的浪费
78-
!function(){ // 立即执行的匿名函数
81+
(function(test){ // 立即执行的匿名函数
82+
console.log(test);
7983
console.log("local data:" + "got");
8084

8185
var localData = "localData hear";
8286
document.addEventListener('click', function(){
8387
console.log("local data:" + localData);
8488
});
85-
}();
89+
})(12345);
90+
91+
// WARMING: Expected an assignment or function call and instead saw an expression. (W030)
92+
// !function(test){
93+
// console.log(test);
94+
// }();
8695

8796
//这种方法使用较多,也最为方便。var obj = {}就是声明一个空的对象
8897
var Circle = {

package-lock.json

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)