3434 *
3535 * */
3636
37- const ctx = {
38- req : {
39- PORT : 123 ,
40- url : 'google' ,
41- } ,
42- res : {
43- status : 1 ,
44- message : 'HELLO' ,
45- header : {
46- contentType : 'application/json'
37+ function Ctx ( ) {
38+ return { req : {
39+ PORT : 123 ,
40+ url : 'google' ,
41+ } ,
42+ res : {
43+ status : 1 ,
44+ message : 'HELLO' ,
45+ header : {
46+ contentType : 'application/json'
47+ }
4748 }
4849 }
4950 }
5051
52+ const ctx = new Ctx ( ) ;
53+
5154const next = function ( ) {
5255 console . log ( "I'm NEXT" ) ;
5356}
@@ -88,31 +91,36 @@ function Human(object) {
8891 this . gender = object . gender ;
8992 this . height = object . height ;
9093 this . weigth = object . weigth ;
94+ this . inheritHuman = function ( ) {
95+ return this ;
96+ }
9197}
9298
93- function Worker ( object ) {
99+ Human . prototype . Worker = function ( object ) {
94100 this . company = object . company ;
95101 this . salary = object . salary ;
96102 this . toWork = function ( ) {
97103 return 'work' ;
98104 }
105+ this . inheritProperties = this . inheritHuman ( ) ;
99106}
100107
101- function Student ( object ) {
108+ Human . prototype . Student = function ( object ) {
102109 this . university = object . university ;
103110 this . grants = object . grants ;
104111 this . toWatchSeries = function ( ) {
105112 return `watch tv series` ;
106113 }
114+ this . inheritProperties = this . inheritHuman ( ) ;
107115}
108116
109117const vasya = new Human ( { name : 'Vasya' , age : '30' , gender : 'Male' , height : '1.8 m' , weigth : '80 kg' } ) ;
110- vasya . __proto__ = new Worker ( { company : 'qwerty' , salary : '007' } ) ;
118+ vasya . Worker ( { company : 'qwerty' , salary : '007' } ) ;
111119console . log ( vasya ) ;
112120console . log ( vasya . toWork ( ) ) ;
113121
114122const sasha = new Human ( { name : 'Sasha' , age : '18' , gender : 'Male' , height : '1.8 m' , weigth : '70 kg' } ) ;
115- sasha . __proto__ = new Student ( { university : 'ytrewq' , grants : '700' } ) ;
123+ sasha . Student ( { university : 'ytrewq' , grants : '700' } ) ;
116124console . log ( sasha ) ;
117125console . log ( sasha . toWatchSeries ( ) ) ;
118126
@@ -127,3 +135,13 @@ console.log(sasha.toWatchSeries());
127135 *
128136*/
129137
138+ function wraper ( func ) {
139+ wraper . prototype . args = 22 ;
140+ return wraper . args ;
141+ }
142+
143+ function sum ( a , b ) {
144+ return a + b ;
145+ }
146+
147+ console . log ( wraper ( sum ( 2 , 2 ) ) )
0 commit comments