JavaScript programming Start (First lesson) _ Basics

Source: Internet
Author: User
Tags control characters numeric value script tag
Whether you've ever learned Java script or not, this tutorial can take you to the halls of Java script and understand the magic of Java script.
People come here, are all Java script enthusiasts, Java script has some degree of understanding. The history of Java script and so on do not introduce, we directly to learn it, with it.
Perhaps most people think Java script is running on the client, but it's not. Java script has two different running environments, one on the server side of JavaScript and the other on the client's JavaScript. Also, JavaScript is also an object-based language.
As the first lesson, just give everyone a simple understanding, things are not too much. There are mainly the following three aspects:
1, add Java script on the page
2. Java Script Data type
3, Java script The most basic three dialog boxes

As for how to add Java script, I think we all know that
<script language= "java Script" >//This line is a Java script tag, followed by a comment
document.write ("Java Script displayed on page")//on page display a word
</script>
/* This is also a comment,
It's just a lot of lines.
*/
I think this is not fine today, to stay in the next lesson, as the homework of this class, is about adapting to various environments Java script
The Add. For browsers that do not support Java script, what should we do to keep the browser from displaying java Script source code, and so on.

The second, which is the most important one today, is the Java Script data type, which has several basic types.
Strings (String)
Numbers (number)
Boolean Value (Boolean)

A string is a sequence of characters. Include letters, numbers, and punctuation. Of course, can also be Chinese characters and so on. A little simpler.
is to represent textual information.

Numbers fall into two categories: integer and floating-point numbers.
Integers include positive integers, 0 and negative integers.

The numbers in Java script can be written in decimal, octal, and hexadecimal. The method is as follows:
Decimal: 15 (write numbers directly)
Octal: 017 (to be zero as the boot number)
Hexadecimal: 0xf (to 0x as the boot number)

Floating-point numbers are also called real numbers, and for convenience, scientific notation can be used to represent:
1.13E1, 1.5e3 (equivalent to 1.5 times 10 of 3)
The number range of Java script is approximately 10 minus 308 times to 10 of the 308-time Square.
There is also a special numeric value Nan (not a number) in the Java script, which the Java script uses Nan to represent the meaningless result.

Boolean value: True and False, 1 is generally true in the computer, and 0 for false.

A null value is NULL, which means nothing.
Undefined value undefined, sometimes equal to null, may sometimes be problematic.
Special characters: Also called escape characters. Are some of the special control characters that are not visible at the beginning of the backslash.
\b: Indicates backspace
\ n: Indicates a newline
Wait a minute.

Use of the alert () method:
<script language= "java Script" >
Alert ("Display a warning dialog on the page");
</script>
Alert () is the Java script that produces a dialog box with a confirmation button that displays the information in parentheses.

Use of the Confirm () method:
<script language= "java Script" >
Confirm ("Show confirmation Dialog on page");
</script>
Confirm () is similar to alert (), and the difference is a cancellation button. Press OK to return true, and return false by canceling.
<script language= "java Script" >
var con;
Con=confirm ("Do you like this kind of tutorial?") ");
if (con==true) alert ("like");
else alert ("Do not like");
</script>

Use of the Prompt () method:
<script language= "java Script" >
var name,age;
Name=prompt ("May I have your name?") ");
alert (name);
Age=prompt ("How old?") ");
alert (age);
</script>
Not only can it display information, but it can also enter information.
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.