js in use:
data verification
Read and write HTML elements
Interact with the browser effect
Netnew
web game production
Programming Node.js server-based technology
javascript part
Common usage of grammar
alert popup: . window.alert () method of the object ()
Writing directly parentheses behind the alert, content inside parentheses written text, text wrapped in double quotes.
console.log (): the console is a console panel output content js built-in object.
(Typeof) data detection
Switch number string +: + when both sides are represented by the digital adder Literals
When both sides are not both number + type, and in particular, numeric string writing, + represents a splicing action.
prompt (): 2 parameter prompt text box
1 Parameters: prompt text
2 parameters: default text
The string into number method: parseInt () integer, parseFloat () float (camelCase)
parseInt (): rounding
parseFloat (): Float
parseInt(): 将字符串转为整数
1 // 参数:书写字符串
2 console.log(parseInt("12.1212"));
3 console.log(parseInt("2333e10"));
4 console.log(parseInt("2333a10"));
结果有可能是NaN
1 console.log(parseInt("a12"));
2 console.log(parseInt("十二"));
3 console.log(parseInt("你好"));
Literal Category: number, string, Boolean value, undefined, null
Any data have data type, such as numbers, strings, arrays, functions, etc.
Data type name:
Simple data types:
number: integer, float, special value
string: String
boolean: true , false
undefined: undefined value contains only one data type number of data types are number Nan
Reference data types:
object (the object)
function (function)
Digital: integer, float, special value
Integer representation: decimal, octal, hexadecimal
Octal: 0,0o, 0O (every eight into a) significant figures 0-7
Hex: 0x, 0X (every hex a) 0-9 af effective than direct digital error
Float: a decimal representation only
Special value:
i nFinity: Due to computer capability effectively, displaying endless Infinity (very large number) exceeds the limit
NaN(not a number)
String
String literal: refers to the variety of life say the words. For example, in various languages, the language of some numbers, punctuation, etc.
String literal: ""
Declare variables:
Variable names (identifiers) naming rules:
The first character can be letters (js case-sensitive), down the line (_), dollar sign $ followed by characters can be letters, _, $, digital
You can not be a keyword or reserved word
Keywords: js have some words functionality.
Reserved words: There are no special features, the future may be retained keywords
Keywords:
break do instanceof typeof case else new var catch finally return void continue for switch while debugger* function this with default if throw delete in try
Reserved words:
abstract enum int short boolean export interface static byte extends long super char final native class
synchronized float package throws const goto private transient debugger implements protected volatile double
import public
Operators
+, -, *, /,% (remainder) modulo the first integer direct multiplication and division count, modulo, and then count subtraction, if there are parentheses in parentheses operator
Pure numeric string involved in computing, a pure numeric string without writing parseInt (), parseFloat (),
// 参数只有一个字符串,不用书写进制参数
// 检测数据类型
console.log(typeof(parseFloat("12.12.1.22444")));
console.log(parseFloat("12.12.1.22444"));
// 浮点数可以使用幂
console.log(parseFloat("1.2e-4"));
// 结果也有可能是NaN
console.log(parseFloat("你好12"));
number
12.12
0.00012
Nan
Automatically determining implicitly converted into corresponding digital involved in computing. (Except for the addition, the addition is still mosaic effect)
// 纯数字字符串,会隐式转换,加法除外,还是拼接作用
console.log(12 - "2");
console.log(12 * "2");
console.log(12 / "2");
console.log(12 % "2");
console.log(12 + "2");
10
24
6
0
122
Infinity involved in computing
-
// Infinity console.log(12 + Infinity); console.log(12 - Infinity); console.log(12 / Infinity); console.log(12 % Infinity); Infinity -Infinity 0 12
NaN result is NaN
-
// NaN运算 console.log(12 + NaN); console.log(12 / NaN);
- undefined involved in computing the result is NaN
// undefined参与运算结果都是NaN console.log(12 + undefined); console.log(12 - undefined); console.log(12 * undefined);
- Non-pure numeric string involved in computing the result is NaN, + or mosaic effect
// 非纯数字字符串参与运算,结果都是NaN,+ 还是拼接作用 console.log(12 - "你好"); console.log(12 * "你好"); console.log(12 + "你好"); NAN NAN 12你好
true, false, null, will be involved in computing implicit conversion. (Addition implicitly converted)
true 1
false 0
null 0
console.log(12 + true);
console.log(12 - false);
console.log(12 * null);
console.log(12 / null);
12+1=13
12-1=11
12*0=0
12/0=Infinity