read table of contents
operator
1. Self-increment operator
let a=11;
alert(++a);
2. Assign values separately
let a,b=12,13; //报错
Object destructuring assignment
let {
name,age} = {
name : '铁扇公主', age : 35};
console.log(name,age);
Array destructuring assignment
let [, b, c, d] = ['abc', 23, true];
console.log(b, c, d);
3. Seek multiple squares
alert(Math.pow(2,3));
alert(7/3);
alert(Math.ceil(7/3));
4. Logical operators in js
console.log(1 && 0);
console.log(1 || 0);
console.log(!0);
type of data
Number、String、Boolean、Null、Undefined、
object(包含普通对象,也包含数组和函数)
Null(空值)类型的值只有一个,就是null
null这个值专门用来表示一个为空的对象
使用typeof检查一个null值时,会返回object
Undefined(未定义)类型的值只有一个,就undefined
当声明一个变量,但是并不给变量赋值时,它的值就是undefined
使用typeof检查一个undefined时也会返回undefined
Determine the variable type
typeof(a)
coercion
There are many methods, such as converting to an integer, you can use operators such as positive and negative signs, you can parseInt, you can use the Number function.
1. Data type
let a=10;
console.log(a);
console.log(typeof(a));
a=10.1;
console.log(a);
console.log(typeof(a));
a="332432";
console.log(a);
console.log(typeof(a));
a=true;
console.log(a);
console.log(typeof(a));
a=null;
console.log(a);
console.log(typeof(a));
a=undefined;
console.log(a);
console.log(typeof(a));
a={
name:'996',age:11};
console.log(a);
console.log(typeof(a));
a=[1,2,3,4];
console.log(a);
console.log(typeof(a));
a=function(){
console.log('aa');}
console.log(a);
console.log(typeof(a));
2. Forced type conversion
coercion
let b="2341";
console.log(typeof(b));
implicit conversion
let b="2341";
let c=--b;
console.log(c);
console.log(typeof(c));
show transition
let b="2341";
let d=Number(b);
console.log(d);
console.log(typeof(d));
let b="2341";
let e=parseInt(b);
console.log(e);
console.log(typeof(e));