-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
157 lines (126 loc) · 4.03 KB
/
Copy pathapp.js
File metadata and controls
157 lines (126 loc) · 4.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
'use strict'
// var myFirstPort;
// myFirstPort = 0.1 + 0.2;
// var myFirstPortA;
// myFirstPortA = 'hello';
// console.log(myFirstPort);
// console.log(myFirstPortA);
// console.log(typeof(myFirstPortA));
// console.log(Math.round(myFirstPort * 10) / 10);
// console.log(myFirstPortA + ' ' + typeof(myFirstPortA));
// console.log(`${myFirstPortA} ${typeof(myFirstPortA)}`);
// var a = null; //Null
// var b = void(0); //Undefined
// console.log(typeof(true)); Boolean
// var myObject = {
// key1: 5,
// key2: 'wet'
// };
// myObject.key1 = 5;
// myObject.['key2'] = 46;
// console.log(typeof(myObject) + ' ' + JSON.stringify(myObject));
// console.log(Object.keys(myObject));
// console.log(myObject instanceof Array);//false
// console.log('' instanceof Array);//false
// console.log(Array.isArray(myObject));//false
// function f() {
// };
// var f2 = () => {};
// console.log(typeof(f));
// [1,2,3].map( function (x){ return x * 2}); //выводит [2,4,6]
// [1,2,3].map (x => x * 2); //выводит [2,4,6] high order function
// function ff(a,b,c) {
// return `Результат ${a+b+c} рублей`; // эконом памяти
// }
// console.log(ff(1,2,3));
// var f3 = (a,b,c) => `Результат ${a+b+c} рублей`;
// //IIFI
// var res = (function(a,b) {
// return `1: ${a == arguments[0]}, 2: ${b == arguments[1]}, 3: ${a == arguments[2]},`;
// })(5,6);
// console.log(res);
// // function f4(...rest) {
// // return `1: ${a == rest[0]}, 2: ${b == rest[1]}, 3: ${a == rest[2]},`; //rest параметры
// // }
// // console.log(f4(1,2,3));
// // var a1 = [1,2];
// // var a2 = [...a1,2,3,4,5];
// // console.log(a2.toString());
// var a1 = [1,2];
// var a1Copy = a1.slice(0,a1.length); // a1.slice
// a1.splice(0,1);
// var a2 = [...a1,2,3,4,5];
// console.log(a1 == a1Copy);
// console.log(a1Copy.toString());
// a1.unshift(1);
// a1.push(3);
// console.log(a1.toString());
// var x = a1.pop();
// a1.shift();
// console.log(a1.toString());
// console.log(...a1Copy); //Ecma 6
// function colorCode(colorName) {
// var colors={ red:'#FF0000', green:'#00FF00', blue:'#0000FF', black:'#000000', white:'#FFFFFF' };
// return colors[colorName];
// }
// console.log( colorCode('red') );
// console.log( colorCode('white') );
// function areArrayEqual(a1, a2) {
// if (a1.length === a2.length) {
// for( var i = 0, n = a1.length ; i < n ; i++) {
// if (a1[i] !== a2[i]) return false;
// }
// return true;
// }
// return false;
// }
// console.log(areArrayEqual([],[]));
// 'use strict';
// const readline = require('readline');
// const result = {
// name:'',
// age:0
// }
// function askName() {
// const rl = prompt();
// rl.question('Какое Ваше имя? ', (answer) => {
// rl.close();
// if (!answer) {
// console.log('Имя не может быть пустым.');
// askName();
// }
// else {
// result.name = answer;
// askAge();
// }
// });
// }
// function askAge() {
// const rl = prompt();
// rl.question('Какой Ваш возраст? ', (answer) => {
// rl.close();
// const age = +answer;
// if (isNaN(age)) {
// console.log('Возраст должен быть введен числом.');
// askAge();
// }
// else {
// result.age = age;
// end();
// }
// });
// }
// function prompt() {
// return readline.createInterface({ input: process.stdin, output: process.stdout});
// }
// function end() {
// console.log(`Вы ввели: имя ${result.name}, возраст ${result.age}`);
// }
// askName();
// 'use strict';
// const readline = require('readline');
// const rl = readline.createInterface({ input: process.stdin, output: process.stdout});
// rl.question('What do you think of Node.js? ', (answer) => {
// console.log(`Thank you for your valuable feedback: ${answer}`);
// rl.close();
// });