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};
710console . log ( obj . x ) ;
811
912// .instanceof运算符: 此运算符可以判断一个变量是否是某个对象(类)的实例,返回值是布尔类型的
10- var str = new String ( "antzone" ) ;
13+ // var str = new String("antzone");
14+ var str = String ( "antzone" ) ;
1115console . log ( str instanceof String ) ;
1216
1317//typeof运算符:此运算符可以返回一个字符串,用语说明元算数的类型
14- var str = new String ( "antzone" ) ;
18+ var str = String ( "antzone" ) ;
1519var strTwo = "antzone" ;
1620console . log ( typeof str ) ;
1721console . 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 = { } ;
3035cat . legs = 4 ;
3136cat . name = "kitty" ;
3237console . log ( cat ) ;
@@ -36,7 +41,7 @@ if (cat.hasOwnProperty('legs')) {
3641var man = {
3742 age : 28 ,
3843 weibo : '@Bosd'
39- }
44+ } ;
4045console . log ( typeof cat ) ;
4146console . log ( typeof man ) ;
4247
@@ -49,14 +54,15 @@ function Person() {
4954Person . prototype . name = 'Kevin' ;
5055var person1 = new Person ( ) ;
5156var 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// --
5661function People ( ) {
5762}
5863var 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
9096Person . prototype . hi = function ( ) {
9197 console . log ( "Hi my name is" + this . name + "i am" + this . age + "years old now" ) ;
92- }
98+ } ;
9399Person . prototype . LEGS_NUM = 2 ;
94100Person . prototype . ARMS_NUM = 2 ;
95101Person . prototype . walk = function ( ) {
96102 console . log ( this . name + "is walking" ) ;
97- }
103+ } ;
98104
99105function Student ( name , age , className ) {
100106 // call调用父类
@@ -110,11 +116,11 @@ Student.prototype.constructor = Student;
110116
111117Student . 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
115121Student . prototype . learn = function ( subject ) {
116122 console . log ( "Hi my name is" + this . name + "is learning" + subject + "at" + this . className + "." ) ;
117- }
123+ } ;
118124
119125var bosn = new Student ( "Bosn" , 29 , "Class3,Grade 2" ) ;
120126console . log ( "new obj type" + typeof bosn ) ;
@@ -140,7 +146,7 @@ class ColorPoint extends Point {
140146}
141147
142148let 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
145151let cp2 = new Point ( 24 , 56 ) ;
146152
0 commit comments