1. <script> label
2. <script src=""></script>
alter()//Warning box pops up
// ''--for String
console.log()//Console output
prompt() //insert the content
3. Parameter(char for all)
// (1)number
let a = 5;
3e8; pow(10,8)*3
3e-8; 3*pow(10,-8)
binary //2b01010
// (2)String
'abc'+'def' == "abcdef"
'' // a null string
string.length
// (3)boolean
// (4)undefined
// (5)null
// (6)changing
// others to Numbers
Number(); parseInt(); paresFloat();
// others to String
String(); toString();
4. Expressions & Operators
(1)cal : + - * /
(2) IEEE754 (toFixed(2))
(3) pow , sqrt
(4) Math.ceil() Math.floor() nearest int
(5)==(type check) ,=(give value) ,===(types and value )
(6)||,&&,+=,++,%=
5. if /else switch
6. Ternary operator (for two)
a>b ? ture: false
if return or return
7. loop: for /while /do while /nest loop
break (out fo the nearest) continue(go to the out of the nearest)
8. array
let Arr =[1,2,3,4,5];
push pop unshift shift
let matrix = [[1,2,3],[3,4,5]];
push(); pop(); shift(); unshift();
slide(); splice();
arrey and string change: join('-'); split();
reverse();
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<script>
//alert('Hello World');
let a = 5;
console.log(a);
let year = 2023;
let name="terry";
console.log(year+name);
let b = Number(prompt("your first Int"));
let c = Number(prompt("your second Int"));
let sum = b+c;
alert(sum);
</script>
</body>
</html>
Copyright notice:
Copyright © 2023, Tanxiaoxu Unauthorized copying or usage of the contents of this article is prohibited.