-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
whj
committed
Dec 30, 2015
1 parent
c4d1f67
commit c50d13a
Showing
4 changed files
with
683 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,27 @@ | ||
module.exports = function(name,age,sex){ | ||
//Constructor | ||
function Student(name,age,sex){ | ||
this.name = name; | ||
this.age = age; | ||
this.sex = sex; | ||
this.study = function(){ | ||
console.log(this.name + ' is busy on study.'); | ||
} | ||
// this.study = function(){ | ||
// console.log(this.name + ' is busy on study.'); | ||
// } | ||
} | ||
|
||
module.exports.desc = function(){ | ||
//Instance method | ||
Student.prototype.study = function() { | ||
console.log(this.name + ' is busy on study.'); | ||
}; | ||
|
||
//Static method | ||
Student.desc = function() { | ||
return 'this is a Student Class'; | ||
} | ||
}; | ||
|
||
|
||
module.exports = Student; | ||
// module.exports.desc = function(){ | ||
// return 'this is a Student Class'; | ||
// } | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
var foo = function(){ | ||
this.value = 100; | ||
}; | ||
|
||
foo.prototype.showVal = function(){ | ||
console.log(this.value); | ||
} | ||
|
||
|
||
|
||
console.log(new foo().value); | ||
|
||
console.log(global.value); | ||
foo(); | ||
console.log(global.value); | ||
|
||
new foo().showVal(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
var fs = require('fs') | ||
|
||
//show nodejs async attr | ||
fs.readFile('js_async_test.txt','utf8',function(err,data){ | ||
if(!err && data){ | ||
console.log('read done 1'); | ||
} | ||
}); | ||
|
||
fs.readFile('js_async_test.txt','utf8',function(err,data){ | ||
if(!err && data){ | ||
console.log('read done 2'); | ||
} | ||
}); | ||
|
||
fs.readFile('js_async_test.txt','utf8',function(err,data){ | ||
if(!err && data){ | ||
console.log('read done 3'); | ||
} | ||
}); | ||
|
||
fs.readFile('js_async_test.txt','utf8',function(err,data){ | ||
if(!err && data){ | ||
console.log('read done 4'); | ||
} | ||
}); | ||
|
||
console.log('end...'); |
Oops, something went wrong.