Skip to content

Commit

Permalink
some test
Browse files Browse the repository at this point in the history
  • Loading branch information
whj committed Dec 30, 2015
1 parent c4d1f67 commit c50d13a
Show file tree
Hide file tree
Showing 4 changed files with 683 additions and 6 deletions.
27 changes: 21 additions & 6 deletions Student.js
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';
// }


17 changes: 17 additions & 0 deletions func.js
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();
28 changes: 28 additions & 0 deletions js_async_test.js
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...');
Loading

0 comments on commit c50d13a

Please sign in to comment.