当前位置:网站首页>Sort out some scattered knowledge points by yourself
Sort out some scattered knowledge points by yourself
2022-07-25 00:55:00 【Classmate Pan Pan】
How to define a function
// Definition of function declaration
function sum(x,y){
return x+y
}
console.log(sum(1,2));
// The form of a function expression
let jian = function(x,y){
return x-y
}
console.log(jian(5,2));
// The form of the constructor
const sum1 = new Function('x' , 'y' , 'return x + y' )
console.log(sum1(1,2));
this Point to the problem
var objList = {
name: 'methods',
getSum: function() {
console.log(this)
}
}
objList.getSum()// Point to objlist, Who calls to whom
function foo() {
console.log(this);
}
foo.apply(undefined);// Point to winodw, If it is null, Is the same
foo.call(objList);// Point to objlist
call apply bind Method
let obj={
name:" Pan Chenyang ",
age:18,
getsum(a,b){
console.log(` My name is ${
this.name}, This year, ${
this.age} Years old! !!!, come from ${
a}, Go to ${
b}`);
}
}
obj.getsum(" nanjing "," anhui ")// My name is panchenyang , This year, 18 Years old! !!!, From Nanjing , Go to Anhui
let obj1={
name:" Song Xingyue ",
age:20
}
obj.getsum.call(obj1," anhui "," nanjing ")// My name is song Xingyue , This year, 20 Years old! !!!, From Anhui , Go to Nanjing
obj.getsum.apply(obj1,[" anhui "," nanjing "])// My name is song Xingyue , This year, 20 Years old! !!!, From Anhui , Go to Nanjing
obj.getsum.bind(obj1," anhui ",' nanjing ')()// My name is song Xingyue , This year, 20 Years old! !!!, From Anhui , Go to Nanjing
obj.getsum.bind(obj1,[" anhui "," nanjing "])()// My name is song Xingyue , This year, 20 Years old! !!!, From Anhui , nanjing , Go to undefined
What we should pay attention to here is :call What is passed is a parameter list ,apply What is passed is an array ,bind Not immediately , Instead, it returns a function , Manual call required
Binary system Decimal system transformation
let num = 65
let str = num.toString(2) //10 Binary to binary
console.log(parseInt(str,2));// Binary conversion 10 Base number
边栏推荐
- asp rs.open sql,conn,3,1中3,1代表什么?
- Verification of Kirchhoff's law and Multisim Simulation (engineering documents attached)
- Unity image control and rawimage
- Esp32 OLED lvgl displays common Chinese characters
- How to implement the server anti blackmail virus system is a problem we have to consider
- Quartus:17.1版本的Quartus安装Cyclone 10 LP器件库
- Install scoop and lux (formerly Annie)
- Example analysis of enum data type in MySQL
- Digital signal processing synthesis matlab design of dual tone multi frequency dialing system
- Current events on July 20
猜你喜欢

What is the root password of MySQL initial installation

7.16 - daily question - 408

Latest information of 2022 cloud computing skills competition

Multi merchant mall system function disassembly Lecture 14 - platform side member level
![[mindspore] [xception model] script statement is suspected to be wrong](/img/86/3174f9edadf4b815a76678551cbfa5.jpg)
[mindspore] [xception model] script statement is suspected to be wrong

Introduction to thread pool

Nodejs package

Detailed usage of iperf
![Detailed explanation of zero length array in C language (1) [information at the end of the article]](/img/89/1f01e24ce52b2d459f26397cd8527f.png)
Detailed explanation of zero length array in C language (1) [information at the end of the article]

7.24 party notice
随机推荐
Join MotoGP Monster Energy British Grand Prix!
Related knowledge of paging
Yolov7:oserror: [winerror 1455] the page file is too small to complete the final solution of the operation
Lambda&Stream
[mindspore ascend] [user defined operator] graph_ In mode, customize how to traverse tensor
C language force buckle the eleventh question to find the maximum capacity of the bucket. (two methods)
This visual is not connected to the presentationsource.
Soft test --- fundamentals of programming language (Part 2)
7.14 - daily question - 408
Netease game Flink SQL platform practice
Screenshot of Baidu map
[performance optimization] MySQL common slow query analysis tools
What is the function of transdata operator and whether it can optimize performance
[mindspore] [training warning] warning when executing training code
Invitation letter | "people, finance, tax" digital empowerment, vigorously promote retail enterprises to achieve "doubling" of economies of scale
[icore4 dual core core _arm] routine 22: LwIP_ UDP experiment Ethernet data transmission
2012.4.13 360 written examination summary
Divide 300000 bonus! Deeperec CTR model performance optimization Tianchi challenge is coming
Install scoop and lux (formerly Annie)
Unity panel control