-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtestQues.html
More file actions
319 lines (306 loc) · 10.5 KB
/
testQues.html
File metadata and controls
319 lines (306 loc) · 10.5 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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>测试题</title>
<link rel="stylesheet" href="css/bootstrap/bootstrap.min.css">
</head>
<body>
<div class="row">
<div class="col-md-12">
<div class="form-horizontal">
<div class="form-group">
<label class="col-sm-2 control-label">普通告警</label>
<div class="col-sm-4">
<input type="text" data-titleid="2" class="form-control input-sm m-t-15 addtableRowInput" value="1000" />
</div>
<div class="col-sm-4">
<input type="text" data-titleid="2" class="form-control input-sm m-t-15 addtableRowInput" value="1000" />
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">重要告警</label>
<div class="col-sm-4">
<input type="text" data-titleid="3" class="form-control input-sm m-t-15 addtableRowInput" value="2000" />
</div>
<div class="col-sm-4">
<input type="text" data-titleid="3" class="form-control input-sm m-t-15 addtableRowInput" value="2000" />
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">紧急告警</label>
<div class="col-sm-4">
<input type="text" data-titleid="4" class="form-control input-sm m-t-15 addtableRowInput" value="3000" />
</div>
<div class="col-sm-4">
<input type="text" data-titleid="4" class="form-control input-sm m-t-15 addtableRowInput" value="3000" />
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">智能告警</label>
<div class="col-sm-4">
<input type="text" data-titleid="1" class="form-control input-sm m-t-15 addtableRowInput" value="" />
</div>
<div class="col-sm-4">
<input type="text" data-titleid="1" class="form-control input-sm m-t-15 addtableRowInput" value="" />
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">阈值开启</label>
<div class="col-sm-4">
<label class="control-label cursor" for="lowCheckbox">低阈值</label>
<input type="checkbox" id="lowCheckbox" class="cursor" data-check="0" style="position: relative;top:3px;" />
</div>
<div class="col-sm-4">
<label class="control-label cursor" for="highCheckbox">高阈值</label>
<input type="checkbox" id="highCheckbox" class="cursor" data-check="0" style="position: relative;top:3px;" />
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">全局设置</label>
<div class="col-sm-9">
<input type="checkbox" class="Globcheckbox cursor" data-check="0" style="margin-top: 22px;" />
</div>
</div>
</div>
</div>
</div>
</body>
</html>
<script src="js/jQuery/jquery.min.js"></script>
<script src="js/bootstrap/bootstrap.min.js"></script>
<script>
function code(){
/*
* 第一题
*/
function make(num){
return function (){
return num;
}
}
var arr = [make(0),make(1),make(2)];
console.log(arr[0]());//0
console.log(arr[1]());//1
console.log(arr[2]());//2
/*
* 第二题
*
*/
var name = 'global';
function A(name){
console.log(name);
this.name = name;
var name = '1';
}
A.prototype.name = '2';
var a = new A('3');
console.log(a.name);
delete a.name;
console.log(a.name);
/*
* 第三题 此题特别重要特别变态!!!!!!
* 切记
*
*/
function fun(n,o){
console.log(o);
return {
fun: function (m) {
return fun(m,n)
}
}
}
var a = fun(0);
a.fun(1);
a.fun(2);
var b = fun(0).fun(1).fun(2).fun(3);
var c = fun(0).fun(1);
c.fun(2);
c.fun(3);
/*
* 第四题
*/
var test = "aaa";
function doSomething(){
console.log(test);
var test = "bbb";
alert("test");
}
doSomething();
console.log(test);
/*=============================
* 第五题
* 详细解析:由于变量提长的原因 些代码等价于
* var userNmae;
* if(!("userName" in window)){
* userName = "zhengzheng.xz"
* }
* console.log(userName)
* 而第一句代码 相当于是全局变量 故其相当于给window添加咯一个userName属性
* 故 “userName" in window 运行结果为true 表示在winow 这个对象中是能够找
* 到userName 这个属性的
* 对"userName" in window 这个结果取非 故if括号里运行结果为false
* 则 userName 声明未赋值 由于js运行规则 声明未赋值的变量默认赋值为undefined
* 故console.log(userName)等价于console.log(window.userName)
* 故运行结果为undefined
*
=================================*/
if(!("userName" in window)){
var userName = "zhengzheng.xz";
}
console.log(userName);//undefined
/*
* 第六题
*
*
*/
var obj = {
user:"zhengzheng.xz",
getName:function(){
return this.user;
}
};
var getNameFn = obj.getName;
console.log(getNameFn());
console.log(obj.getName());
/*
* 闭包的精典应用场景
*
*
*/
// for(var i = 0,els = document.getElementsByClassName("element");i<els.length;i++){
// (function(index){
// els[index].onclick = function(){
// console.log(index);
// }
// })(i);
// }
}
//1、请写出弹出值并解释为什么 5分
+function(){
alert(a)
a();
var a = function(){
console.log(1);
}
function a(){
console.log(2);
}
alert(a)
a();
var c = d = a;
}();
alert(d);
alert(c);
/*
* 解析:表达式 (function(){}()); (function(){})(); +function(){}();-function(){}();!function(){}();~function(){}(); 此函数表达式会返回一个结果
* 函数提升:test() function test(){};与function test(){} test();一样执行
* 变量提升:
* if(false){
* var a = 1;
* }
* console.log(a);//undefind (not a is not defined);
* 此题是考验一个前端是不是入门的一个基础题
* 函数提升的优先级要比变量要高
*
*
*
*/
// 2、请写出如下输出值,并写出把注释掉的代码取消注释的值,并解释为什么 8分
this.a = 20;
var test = {
a:40,
ini:()=>{
console.log(this.a);
function go(){
// this.a = 60;
console.log(this.a);
}
go.prototype.a = 50;
return go;
}
};
// var p = test.init();
// p();
new(test.init())();
//答:
//去掉注释后的答案
// 3:请写出如下点击li的输出值,并用三种办法正确输出li里的数字 12分
// <ul>
// <li>1</li>
// <li>2</li>
// <li>3</li>
// <li>4</li>
// <li>5</li>
// <li>6</li>
// </ul>
var list_li = document.getElementsByTagName("li");
for(var i = 0;i<list_li.length;i++){
list_li[i].onclick = function(){
console.log(i);
}
}
// 4、写出输出值并解释为什么 5分
function test(m){
m = {v:5}
}
var m = {k:30};
test(m);
alert(m.v);
/*
* 5、请在下面写出javascript面向对象编程的混合式继承。交写出ES6版本的继承。
* 要求:汽车是父类,Cruze是子类。父类有颜色 ,价格属性 ,有售卖的方法。Cruze子类
* 实现父类颜色是红色,价格是140000,售卖方法实现输出如下语句:将红色的Cruze买给咯
* 小王的价格是14万。20分
*/
/*
* 6、 请用一句话算出0-100之间学生的等级,如90-100输出为1等生,80-90为2等生以此类推。
* 不允许使用if switch 等 10分
*/
/*
* 7、请你写出如何利用ECMAScript6/7(小demo)优化多步异步嵌套的代码?
*/
/*
* 8、请问点击 <button id = "test" ></button>会有反应么?为什么?能解决么?
*/
$("#test").click(function(argument){
console.log(1);
});
setTimeout(function(){
console.log(2)
},0);
while (true){
console.log(3);
}
//9、请用一句话遍历变量a。(禁止用for已知var a = "abc")(10分)
//10、请写出如下输出值,并解释为什么? 12分
var s = [];
var arr = s;
for(var i =0 i < 3;i++){
var pusher = {
value:"item"+i
},tmp;
if(i != 2){
tmp = [];
pusher.children = tmp;
}
arr.push(pusher);
arr = tmp;
}
console.log(s[0]);
/*
* 附加题 请描述你理解的函数式编程,并书写如下代码结果。如何
* 将函数式编辑应用到你的项目当中呢?10分
*/
var Container = function(x){
this._value = x;
}
Container.of = x => new Container(x);
Container.prototype.map = function(f){
return Container.of(f(this._value))
}
Container.of(3)
.map(x => x+1)
.map(x => 'Result is' + x);
</script>