当前位置:网站首页>2021 Yahong pen test question 2
2021 Yahong pen test question 2
2022-07-28 15:55:00 【PBitW】
List of articles
Code running problem

Here is actually to test two knowledge points :
static

Reference address :
https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Classes/static
constructor Construction method ( More detailed )
new When a function , Will directly execute the construction method of this function ( Be similar to java), The constructor points to the object , So you don't introduce anything , It still has newColor="green" This thing !
distinguish
We need to distinguish Constructor and constructor !
Constructors It is generally capitalized , be used for new Function of the object , Usually inside Properties or methods are used this To define , and Construction method It is a prototype chain inside a function ,new When a function , Methods that will be executed directly , Also and this Hooked up !
JavaScript in new Operator is used to create an object instance of a given constructor . The following example :
function Person(name, age){
this.name = name;
this.age = age;
}
const person1 = new Person('Tom', 20)
console.log(person1) // Person {name: "Tom", age: 20}
We defined a constructor Person, And then through new Operators generate Person Reference an instance of the constructor and assign a value to it person1. Then print it out from the console person1 The content of , You can see that the instance object has name and age attribute , Their values are the values we pass in when we call the constructor .
that , We use new What happens when operators ?
thank :JavaScript Medium new Principle analysis of operators
JS The difference between constructor and ordinary function in
1、 The constructor is also an ordinary function , The creation method is the same as that of ordinary functions , but Constructors are used to capitalize
2、 The difference between a constructor and a normal function is : It's called in different ways , It's not the same ( Constructors are used to create new instance objects )
3、 The function name of the constructor is the same as the class name :Person( ) This constructor ,Person Is the function name , It's also the class name of this object
4、 For internal use this To construct properties and methods
5、 use instanceof You can check whether an object is an instance of a class , Yes, go back to true; All objects are Object Descendants of objects , So any object and Object do instanceof Will return to true
Reference resources :JS The difference between constructor and ordinary function in
Prototype attribute

Be careful
there Objects are instance objects , No object object , In the back and in the front !




thank : Thoroughly understand JavaScript Prototype chain ( One )—__proto__ Default point of
Objects and functions
js The object and function definitions of are the same , however new What comes out is the object , The direct use is the function !
Code running problem ( Template string 、 Tag function )


Programming problem ( Determine style –> Change the style )

answer :https://blog.csdn.net/Eva3288/article/details/108140003
The rookie is stupid , The easiest thing to think of The zoom (zoom,transform) and max-width little does one think !!!
then box-sizing: border-box;padding: 0 50px; This is really a test , Before you see it , I thought I would cut the picture , The result turned out to be a squashed picture !
js The rookie thought of a way , But I didn't write the code , The answer of the rookie :
The first is wrong ! What the rookie thinks is flex-basis To cover width attribute , But it turns out not , This method is right for div,span It works , however img no way !
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style> /* no way */ div{
width: 500px; display: flex; } div img{
width: 400px; flex-basis: 250px; } div span{
display: inline-block; width: 400px; height: 300px; background-color: aqua; flex-basis: 250px; } /* feasible */ /* img{ max-width: 300px; } */ /* img{ box-sizing: border-box;padding: 0 50px; } */ </style>
</head>
<body>
<div>
<!-- <img src="./logo.png" style="width: 400px !important;"/> <img src="./logo.png" style="width: 400px !important;"/> -->
<img src="./logo.png" />
<img src="./logo.png" />
</div>
<div>
<!-- <span></span> -->
<span></span>
</div>
</body>
</html>
I hope that readers who understand me can come and communicate !
The way of animation doesn't matter , Basically, these are the key points !
Code running problem ( Type conversion )

Type conversion table


Be careful :
Please be sure to write down these things , The written examination is really easy !
Add
toString

Be careful
- A string of ‘true’ = = true perhaps ‘true’ = = = true It's all back false,false Empathy !
however
valueOf

Object to original value

Be careful :
js There are only undefined、null、""、0、NaN Turn into Boolean The type is false!
Implicit conversion of objects

== Implicit transformation of

Comparison operator type conversion

+ Implicit transformation of


Be careful :
So there are strings + Time will not continue to be converted into numbers , But connected !
summary
Basically is : No matter calculation or comparison , All of them convert operands into numbers or strings for comparison ! And type conversion is really important , Many written examinations will be taken , You must remember !!!
So the above running results :
边栏推荐
- Late 2021 year-end summary
- 一波骚操作解决Laya场景编辑器报错问题
- Multifunctional mixed signal AI acquisition / switching value di/do acquisition to rs485/232/modbus module
- Communication between client and server based on rsocket protocol
- 高精度绝对角度传感器应用高速度角度监测
- 突发!微星CEO江胜昌坠楼身亡
- 12V脉冲转速测量转24V电平信号转换变送器
- Rust 入门指南(rustup, cargo)
- Shell programming specifications and variables
- 使用systemd管理服务
猜你喜欢

js 双向链表 01

Rust 入门指南(crate 管理)

VM501开发套件开发版单振弦式传感器采集模块岩土工程监测

How to effectively conduct the review meeting (Part 1)?

光学雨量计应用降雨量检测

如何有效进行回顾会议(上)?

Learn about the native application management platform of rainbow cloud

占空比开关量输出高速脉冲计数器RTUModbus模块IBF63
![[wechat applet development (VII)] subscription message](/img/aa/f0c68bc0c068ac208820df42cce3db.png)
[wechat applet development (VII)] subscription message

js 优先级队列
随机推荐
远距离串口服务器( 适配器)UART/I2C/1-Wire/SPI PS304常见问题及注意事项
Software architecture and design (VI) -- hierarchy
js 双向链表 01
Software architecture and design (VII) -- interactive architecture
Late 2021 year-end summary
振弦采集模块测量振弦传感器的流程步骤?
A failed cracking experience
高速计数器转RS485Modbus RTU模块IBF150
Shell编程规范与变量
分体式测斜探头安装要点及注意事项
记:数值向上取整十,整百,整千,整万
2021 亚鸿笔试题2
Rust Getting Started Guide (rustup, cargo)
Virturalbox solves the problem of kernel driver
How to quickly access the unified authentication system
The advanced path of programmers
Set static IP in NAT mode of virtual machine
js 队列
深部位移监测系统wk813应用边坡、大坝、堤防、铁路和建筑基坑开挖等深部位移测量
Zhaoqi scientific innovation and entrepreneurship competition platform, activity roadshow, investment and financing docking

