Home  >  Article  >  Web Front-end  >  Detailed explanation of examples of common type conversions in JS

Detailed explanation of examples of common type conversions in JS

零下一度
零下一度Original
2017-07-24 16:16:331030browse

This article mainly introduces common type conversions and operator expressions involved in JS, including common type conversions and commonly used operator expressions in JS. Friends in need can refer to the following

Commonly used type conversions in JS (usually forced conversion):

1. Forced conversion to integer: parseInt; writing method: x = parseInt(x );

2. The forced conversion bit is: parseFloat; writing method: x = parseFloat(x);

3. Detection type: x = parseInt(x); alert(typeof(true));

Commonly used operator expressions in JS:

1. Logical operators (Boolean): && and;|| or;! Not ;

2. Comparison operator: == (equal to) ;! = (not equal to); >; <;>= (greater than or equal to); Remainder); +=; +-;

4. Other operators: concatenation of strings (numbers and strings);

For example:

var s1 = "hello" ;Value 1; Value 2; For example: a==b?"A equals B":"A is not equal to B";

The above is the detailed content of Detailed explanation of examples of common type conversions in JS. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn