JavaScript basic data types and operations

Source: Internet
Author: User

<!doctype html>
<meta charset= "Utf-8" >
<title> Untitled Document </title>


<script type= "Text/javascript" >
function Test1 () {
Window.alert ("You clicked Button");
}
function Test2 () {
Define two variables and assign a value
var num1=2;
var num2=3;
var res=num1+num2;
Window.alert ("num1+num2=" +res);
}
function Test3 () {
var name= "Hello";
Window.alert (the type of name is: "+typeof name");
}
function Test4 () {
var a= "Hello";
var a= "World";
Window.alert (A + "--" +a);
}
function Test5 () {
var n1=0x8a;
var n2=0010123;
var n3=1234;
Alert (n2);


}
function Test6 () {
var s= "abc";
The parseint () function is a global function of JS and can be used directly
Where to find
Alert (parseint (s));
var r=7/0;
Alert (R);
}
function Test7 () {
Window.alert ("False, 0," ", null, Undefined, Nan these represent false");
var a=10;
if (a) {alert ("true")}
Else{alert ("false")}
}
function Test8 () {
Window.alert ("Hello,china");
}
function Test9 () {
var num1=window.prompt ("Please enter the first number:");
var num2=window.prompt ("Please enter a second number:");
var res=parsefloat (NUM1) +parsefloat (num2);
Window.alert ("The result is:" +res);
}
function A () {
Window.alert ("+ 、-、 *,/,%");
}
Function B () {
var jia=2+3;
var jian=3-2;
var cheng=2*3;
var Chu=6/3;
Window.alert (jia+ "--" +jian+ "--" +cheng+ "--" +chu ");
}
</script>
<body>
JS Starter Program <br/>
<input type= "button" value= "Hello,world" onclick= "Test1 ()" >
JS Variables and Operations <br/>
<input type= "button" value= "JS Variable and operation" onclick= "Test2 ()" >
JS variable type is determined by the JS engine, if you want to see the type of a variable, you can use the TypeOf operator <br/>
<input type= "button" value= "JS variable type" onclick= "Test3 ()" >
Variable usage Precautions:<br/>
1. Variable Case sensitivity <br/>
<input type= "button" value= "Note 1" onclick= "test4 ()" >
JS data types are <br/>
Basic data type [1. Integer 2. Real number 3. BOOL 4. String]<br/>
Composite data type [1. Array 2. Object]<br/>
Special data type [1. Null 2. undefined]<br/>
<input type= "button" value= "integer" onclick= "Test5 ()" >
<input type= "button" value= "real" onclick= "Test6 ()" >
<input type= "button" Value= "boolean" onclick= "Test7 ()" >
<input type= "button" value= "character" onclick= "Test8 ()" >
JS Data type Conversion <br/>
<input type= "button" value= "JS Calculator" onclick= "Test9 ()" >
JS Operators <br/>
<input type= "button" value= "JS operator" onclick= "A ()" >
<input type= "button" value= "Operation Case" onclick= "B ()" >
JS bit arithmetic, logic operation <br/>
<a href= "http://blog.csdn.net/dzy21/article/details/46986193" > Reference articles </a>
</body>

Operation Result:


These are only the knowledge that must be mastered, to broaden their horizons to see more JS documents can be, the latter will continue to update.

Copyright Notice: Bo Master original articles, reproduced please indicate the source. Http://blog.csdn.net/dzy21

JavaScript basic data types and operations

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.