A computer language, the core of programming lies in logical thought, when we are writing programs, whether logic is smooth, is the key to write programs correctly, it can be said that if you master logic, then you will step into the door of computer programming.

&& and | | or! no

Logic and &&

var a=0,b=3;

alert(a==0&&b==3) //true;

alert(a==1&&b==3)//false;

Its return value is Boolean, and the entire statement returns true if both conditions are true. Return false if one of them is not true;

Logic or | |

var a=0,b=3;

alert(a==1||b==3) //true;

alert(a==0||b==4)//true;

alert(a==10||b==40)//false;

Its return value is Boolean, and the entire statement returns true if one of the criteria is true. Return false if none of them are true;

Logical not!

var a=0,b=3;

alert(a! =1) //true;

alert(b! =3)//false;

Its return value is Boolean, and the entire statement returns true if the condition is not true. If true then return false;

Since the increase

At a certain point in time, after a particular event, it changes.

A ++, a– the return value is a itself, because browsers parse from top to bottom left to right. When we read this statement, variable A is the first to be parsed. It has not performed any operations yet, so the result of this statement is variable A.

var a=1;

alert(a++); / / 1.

alert(a++); / /??????

++a, –a Similarly, because of the parsing order, when the parser

Alert (+ + a); / / 2

NaN(a special number type that is different from itself, indicating a number that is not a number)

alert(NaN==NaN)//false

var a=0;

var b;

var c=a+b

alert(c);

//isNaN(num) function, which determines whether the value of num is a NaN

alert(isNaN(c));

Number() method toFixed() method

Number Casts data of any type and converts the result to a Number.

alert(Number(true)); Boolean types true and false are converted to 1 and 0, respectively

alert(Number(25)); //25, the numeric type directly returns

alert(Number(null)); // the null object returns 0

alert(Number(undefined)); //NaN, undefined returns NaN

Var a = 1.22222

A.tofixed (2)// Returns 1.22

A / / 1.22222

If it is an object, the toString method is called to get the return value after converting the number fails.

var box = {

toString : function () {

return ‘123’; // return ‘ABC’

}

};

alert(Number(box)); / / 123

Create an Object type

There are two ways to create it

1.var obj=new Object();

2.var obj={

}

The parseInt () and the parseFloat ();

Cast data, what’s the difference between them?

ParseInt () this method checks the first non-numeric character in a number or string from left to right and returns all the preceding characters. If the first non-numeric character in the string is NaN;

Ex. :

1. ParseInt (‘123abc’) a is the first non-numeric character; Returns all values up to a, the method returns 123.

2. ParseInt (‘abc123’)a is the first non-numeric character at the beginning of the string, and the string cannot be converted to a number.

ParseFloat () This method retrieves the first one after a number or string. The last non-numeric character, and returns all previous results, or NaN if the first character is not a number.

Ex. :

1. The parseFloat (‘ 123.123.123 ABC ‘). The first. Non-numeric character then returns the previous character. This method returns 123.123