JavaScript is a weakly typed language, and the variable type of JavaScript is determined by its value. To define a variable, you need to use the keyword 'var'
var iNum = 123; var sTr = 'asd'; //同时定义多个变量可以用","隔开,公用一个‘var'关键字 var iNum = 45,sTr='qwe',sCount='68';
Variable type
Five basic data types:
1, number numeric type
2. string string type
3. boolean Boolean type true or false
4. undefined undefined type, the variable declaration is not initialized, and its value is undefined
5. null The null type represents an empty object. If the defined variable is going to save the object in the future, the variable can be initialized to null. If the object cannot be obtained on the page, the returned value is null
A composite type :
object
javascript statements and comments
1. A javascript statement should end with ";"
2. JavaScript comments
Variables, functions, properties, and function parameter naming conventions
1. Case-sensitive;
2.The first character must It is a letter, underscore (_) or dollar sign ($);
3. Other characters can be letters, underscores, dollar signs or numbers
Recommended tutorial:js tutorial
The above is the detailed content of Introduction to the basic usage of js variables. For more information, please follow other related articles on the PHP Chinese website!