Getting started with JavaScript

Source: Internet
Author: User
Tags float double

In JavaScript, data types are classified into integer and floating-point types. Here, the floating-point type does not have the same single-precision or double-precision expression. The declaration of all variables only needs to use var (which is easy, do not record int long float double ......) What type of value you pay for it, and what type it is. Also, do not distinguish between characters and strings. In the past, sometimes, when using C #, it seems that "… Cannot be used as a string ". It's easy to remember, haha ............
The String type is similar to the string type in other languages. You can perform operations on the String, such as string truncation substring. The following is an example of a JavaScript string operation:
Copy codeThe Code is as follows:
<Title> Example 2-10 </title>
<Script language = "javascript">
<! --
// Poetry content
Var comment = "quiet night, Li Bai, bed, bright moonlight, suspected to be frost on the ground. Look up at the moon and look down at your hometown. ";
Var partial = comment. substring (0, 3); // retrieve the title
Partial = partial. bold (); // The title is bold.
Document. write ("<p align = \" center \ ">"); // output the HTML Tag "<p>" and set center alignment
Document. write (partial); // output title
Partial = comment. slice (3, 5); // retrieve the author
Document. write ("<br/>"); // output line feed tag <br/>
Document. write (partial); // output author
Partial = comment. slice (5, 17); // extract the first poem
Partial = partial. fontcolor ("gray"); // set the color to gray)
Document. write ("<br/>"); // output the line feed label.
Document. write (partial); // output the verse
Partial = comment. slice (17, 29); // extract the second poem
Partial = partial. fontcolor ("gray"); // set the color to gray)
Document. write ("<br/>"); // output the line feed label.
Document. write (partial); // output the verse
Document. write ("</p>"); // output the end tag of the HTML Tag "<p>"
-->
</Script>

Composite data types in JavaScript
Arrays and functions are also available in JavaScript. The definition of arrays is similar to that of C # And C ++.
The following is an example of an array:
Looking at the sudden appearance, there is an interesting operator in JavaScript, "=", which is used to determine whether data is equal, the data must be equal not only in values but also in data types. Oh, this is a bit dizzy.
Copy codeThe Code is as follows:
<Script>
<! --
Var x = 10;
Var y = null;
If (x = null)
{
Document. write ("the value of x is null <br/>"); // output a prompt
}
If (null = y)
{
Document. write ("the value of y is null <br/>") // output a prompt
}
-->
</Script>

Conversion of values in JavaScript
There are also conversions of numeric types in JavaScript, including display conversions and implicit conversions, which are basically similar to those of C ++. As this is a note, I will not write it.
Like almost all WEB programming languages, "=" and "=" are different. One is to determine whether the values are equal, and the other is to determine whether the values and types are completely equal. I want to take notes separately later. It's already quite long. For me, I have never written such a long thing ...... There is no habit of writing notes separately.
It's sent here today ...... Continue later.
Good study, day up!

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.