当前位置:网站首页>JS knowledge points
JS knowledge points
2022-07-16 06:58:00 【Springxing star】
javascript Is a weakly typed scripting language that runs on Web pages
Weak type : That is, you do not need to specify the data type when declaring variables , Decide when assigning
Scripting language : Small volume , Incomplete programming language
cmd,( Suffix is .bat The file is also a scripting language )
Three ways of writing
① Directly in html Write in Tags
<input type="button" value=" Button " οnclick="alert('Hello js')">
② stay body It's written inside script middle
<script>
alert("Hello js");
</script>
stay head It's written inside script, To write a load function
<script>
window.onload = function(){
alert("hello js");
}
</script>
③ Lead to the outside js file
<script src="../js/03-js"></script>
external js Also write the loading function
js Component part
1.js The core grammar of
2.DOM operation ( use js operation HTML and CSS)
3.BOM operation ( use js Operating the browser )
js The core grammar of
Variable : The amount of data that changes
The essence of a variable is a container , There is a data inside
Declare variables :var Variable name = value
The variable name should not be in Chinese , Do not start variable names with numbers , When you choose a variable name, you need to know its meaning
data type
① Basic data type
1.number( The number ) 2.string( character string ) 3.boolean( Boolean type ) 4.undefined( Undefined ) 5.null( Assigned but empty )
② Reference data type
object,array,function,date, Custom object
Operator
Arithmetic operator (+,-,*,/,%,++,--,** yes x Of y Power )
Comparison operator (>,<,>=,<=,==,!=,===)
Logical operators :&,|,&&,||
One 、 Branching structure
①if Single branch statements
②if..else Two branch statements
③if..else if...else Multi branch statement
Two 、 Loop statement
for loop
for( Initialization statement ; Judgment statement ; Iteration statement ){
Execute statement ;
}
while loop
Initialization statement ;
while( Judgment statement ){
Execute statement ;
Iteration statement ;
}
do...while loop
Initialization statement
do{
Execute statement ;
Iteration statement ;
}while( Judge the condition )
Mathematical statement
math.floor() Rounding down
math.ceil() Rounding up
math.round() rounding
math.random() Take random number
continue Out of the loop , And back there perform
break Out of the loop , Don't follow
Dead cycle :while(true){
}
for(;;)
Small space &emsp Big space ( amount to 2.5 Small spaces )
DOM operation :
DOM:JS Code changes html Label object ( Property value , Text value )
1. obtain html Label element object
1. Assign a value to an object's property , Change attribute value , Get attribute value (classname)
Yes html Tag's own properties , You can call directly with the element object css attribute , Put it in style Integration properties , therefore : Element object .style. attribute
bg.style.positionX=x+'px'
Two ways to delete
① Element delete children
ele.remove();
② Delete the child element through the parent element
fu,removeChild(zi)
parentNode: Get parent node
parentElement: Get parent element
this Represents the current object ( Method call )
Under function call ,this Point to window
es6 New characteristics :
const Constant
let Variable
边栏推荐
- 史上最快上手Redis(附加连接云服务器上的Redis)
- Leetcode-2 addition of two numbers (head insertion, tail insertion of linked list, addition and subtraction of two linked lists with different lengths)
- 使用Pygame制作2048小游戏
- Matlab warning: name does not exist or is not a directory
- Import word document pictures root file system production and mounting
- Excel-2
- Get Erlang installation package for free!!
- 黑马数据库笔记DQL
- Promise --- synchronize? Asynchronous?
- [Go语言入门] 13 Go语言接口(interface)详解
猜你喜欢
随机推荐
三分钟上手Markdown——基本语法快速入门
DL第五天
How to solve the win10 installer prompt "cannot open the file xxxxx to be written"
Chapter V stm32+ld3320 speech recognition control Taobao USB dormitory desk lamp
SQL基础1
Stm32-tim3 output PWM signal to drive mg996r steering gear (key control)
使用Idea IntelliJ查看字节码文件
一盏茶的功夫我学会了JWT单点登录
STM32 uses a simple method to control many lights to achieve the effect of flowing water
数据库黑马笔记DML
LeetCode 第十八天
02 featurescaling normalization
RT_ Thread idle thread and two commonly used hook functions
How to select embedded single chip microcomputer?
[Go语言入门] 05 Go语言分支语句
[Go语言入门] 11 Go语言函数
Pyopencv basic operation guide
将字符串s1中所有出现在字符串s2中的字符删除
[Go语言入门] 07 Go语言字符串
Redis is the fastest to get started in history (attach redis on ECs)









![[introduction to go language] 08 go language array](/img/f6/6e113d9090a0c58a68b2e379e64500.png)