Javascript BASICS (1), Javascript BASICS (
My CSDN blog address: http://blog.csdn.net/caicongyang 1. Five primitive types of Javascript
Undefined, Null, String, Boolean, Number
The Undefined data type has only one value: undefined
Null data type has only one value: null
Values of the Boolean data type include true and false.
Demo:
<script type="text/javascript"> alert(typeof s);//undefined var falg = true; alert(typeof falg);//boolean var s1 ="hello"; alert(typeof s1);//string var s3 = 3; alert(typeof s3);//number var s4 = null; alert(s4);//null var s2 = new String("hello"); alert(typeof s2); //object alert(undefined == null);//true </script>
2. Forced type conversion Boolean (value) Number (value) String (value)
3. Array
<Script type = "text/javascript"> // first definition method var arr1 = new Array (3); arr1 [0] = "apple "; arr1 [1] = "HTC"; arr1 [2] = "Haiwei"; alert (arr1.length); alert (arr1 [0]); alert (arr1.valueOf ()); // value: arr1.reverse (); // reverse order: alert (arr1.toString (); // value: arr1.push ("xiaomi"); // Add the element alert (arr1.toString ()); arr1.shift (); // Delete the first element of the array, alert (arr1.toString (); alert (arr1.pop ()); // Delete and return the last element of the Array // The second definition method var arr2 = new Array ("apple", "plum", "banana "); // method 3: var arr3 = ["headset", "Mobile Phone"]; </script>
My CSDN blog: http://blog.csdn.net/caicongyang
Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.