Javascript BASICS (1), Javascript BASICS (

Source: Internet
Author: User

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.

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.