Data
Data type is very important, it is the premise of computer operation Security.
Common data types in JavaScript are: numbers, strings, Boolean values (Ture or FALSE)
All data types are: String, number, Boolean, null, undefined, symbol.
Use variables to store numbers
When the carpenter is making the table, he needs to calculate the length, width and height of the table, and when the computer calculates the area of the table, it also needs to record the length and width of the table, which are numbers.
<
body
>
<
script
>
// 声明一个变量,用于临时存储桌子的长度
var length;
length=80;
var width=60;
document.writeln(‘桌子宽‘+width + ‘<
br
>‘);
document.writeln(‘桌子长‘ +length+ ‘<
br
>‘);
document.writeln(‘桌子的面积是‘ + width*length);
</
script
>
</
body
>
use variables to store strings
Strings are most frequently used in computers, and strings are used to remember names, text, and so on.
characters in JavaScript are enclosed in a pair of double quotation marks ("") or a pair of single quotation marks (") .use quotation marks in a string
Many times, you need to use single or double quotation marks in a string.
How to use it?
If you want to use double quotation marks in a string, you must use single quotation marks to enclose the entire string .
If you want to use single quotation marks in a string, you must use double quotation marks to enclose the entire string .
Use variables to store Boolean values
A condition that a Boolean value is commonly used in a computer to make judgments.
ar
b =
true
;
if
(b) {
document.write(
""
);
}
else
{
document.write(
""
);
}
Test Questions
1. What are the common data types in JavaScript?
A: number, string, boolean value (Ture or False)
2. How do I use double quotes in a string?
A: If you want to use double quotation marks in a string, you must use single quotation marks to enclose the entire string .
Javascript&jquery.2javascript data