JavaScript Learning Introductory Tutorials _ Basics

Source: Internet
Author: User
Tags float double numeric
In JavaScript, the data type is divided into integral and floating-point types, where the floating-point type has no single or double precision, and all variables are declared with Var only (well, don't remember int long float double ...). What type of value you pay it, and what type it is. Also do not distinguish between characters and strings, in the past seems to have sometimes, in the use of C # as if there is "... cannot be used as a string. It's easy to remember, haha .....
String types are similar to string-type methods in other languages, and can operate on team strings, such as intercepting substring () of strings. The following is an example of a JavaScript string operation:
Copy Code code as follows:

<title> Example 2-10</title>
<script language= "JavaScript" >
<!--
The content of the poem
var comment = "Quiet night thinking Li Bai bed before Ming moonlight, doubt is on the ground frost." Looking up at the moon, head to think of home. ";
var partial = comment.substring (0, 3); Remove title
partial = Partial.bold (); Title Bold
document.write ("<p align=\" Center\ ">"); Output HTML Tag "<p>" and set center alignment
document.write (partial); Output title
partial = Comment.slice (3, 5); Remove author
document.write ("<br/>"); Output Line Wrap label <br/>
document.write (partial); Output author
partial = Comment.slice (5, 17); Take out the first verse
partial = Partial.fontcolor ("Gray"); Set color to Gray (gray)
document.write ("<br/>"); Output Line Wrap Label
document.write (partial); Output verse
partial = Comment.slice (17, 29); Take out the second verse
partial = Partial.fontcolor ("Gray"); Set color to Gray (gray)
document.write ("<br/>"); Output Line Wrap Label
document.write (partial); Output verse
document.write ("</p>"); End tag for output HTML tag "<p>"
-->
</script>

Composite data types in JavaScript
There are also arrays and functions in JavaScript. The definition of an array is similar to the c#,c++.
The following is an example of an array:
Looking at the sudden discovery that there is a very interesting operator in javascript "= = =" This is used to determine whether the data is equal, not only in the number of equal and also in the data type equal, oh this is still a little dizzy.
Copy Code code as follows:

<script>
<!--
var x = 10;
var y =null;
if (x==null)
{
document.write ("Value of x is null <br/>"); Output hint
}
if (null==y)
{
document.write ("Y value is null <br/>")/output prompt
}
-->
</script>

numeric conversions in JavaScript
There are also numeric conversions in JavaScript that show conversions and implicit conversions are basically similar to C + +, because they are notes, so they are not written.
As with almost all Web programming languages, "= =" and "= =" are different, one is to determine whether the value is equal, one is to determine whether the value and type are exactly equal. This is still in the future alone to make notes, has been compared to me for a long time, did not write such a long thing, hehe ... There is no habit of writing notes alone.
Send to here today, hehe ... Let's go on slowly later.
Good good STUDY, day up!

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.