Home > Web Front-end > JS Tutorial > Getting Started with JavaScript Programming (Lesson 1)_Basic Knowledge

Getting Started with JavaScript Programming (Lesson 1)_Basic Knowledge

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-05-16 19:21:19
Original
1062 people have browsed it

Regardless of whether you have learned javascript before, this tutorial can take you into the palace of javascript and appreciate the charm of javascript.
Everyone here is a lover of javascript, and they all have a certain understanding of javascript. I won’t introduce the history of javascript. Let’s just learn it and use it.
Perhaps most people think that javascript runs on the client, but this is not the case. There are two different running environments for javascript, one is javascript on the server side, and the other is javascript on the client side. Also, JavaScript is also an object-based language.
As the first lesson, I just give you a simple understanding, there is not too much. There are mainly three aspects:
1. Add java script to the page
2. Data types of java script
3. The three most basic dialog boxes of java script

About how to add Java script, I think everyone knows, is


/*This is also a comment,
is just multi-line.
*/
I don’t think I will go into detail about this today. I will leave it to the next lesson. Let’s consider it as the homework for this lesson, which is about adding javascript
to adapt to various environments. If the browser does not support javascript, what should we add to prevent the browser from displaying the source code of javascript, etc.

The second one, which is the most important one to talk about today, is the data type of javascript, which mainly includes the following basic types.
String
Number
Boolean

A string is a sequence composed of a series of characters. Includes letters, numbers, and punctuation marks. Of course it can also be Chinese characters, etc. Simply put,
represents text information.

Numbers are divided into two categories: integer numbers and floating point numbers.
Integers include positive integers, zero and negative integers.

Numbers in javascript can be written in decimal, octal and hexadecimal. The method is as follows:
Decimal: 15 (just write the number directly)
Octal: 017 (use zero as the leading number)
Hexadecimal: 0xf (use 0x as the leading number)

Floating point numbers are also called real numbers. For convenience, they can also be expressed using scientific notation:
1.13e1, 1.5e3 (equivalent to 1.5 times 10 raised to the third power)
java The numerical range of script is approximately between 10 to the power of negative 308 and 10 to the power of 308.
There is also a special numerical value NaN (not a number) in java script. Java script uses nan to represent this meaningless result.

Boolean values: true and false. In computers, 1 is generally used to represent true, and 0 is used to represent false.

The empty value is null, which means it does not represent anything.
The undefined value is undefined, sometimes equal to null, sometimes there may be a problem.
Special characters: also called escape characters. are some non-displayable special control characters starting with a backslash.
b: means backspace
n: means line break
etc.

Use of the alert() method:


alert() is a java script that generates a dialog box with a confirmation button, which displays the information in brackets.

Use of confirm() method:


confirm() is similar to alert(), the only difference is that there is an extra cancel button. Pressing OK returns true, pressing Cancel returns false.

<script> //这行是java script脚本标记,斜杠后面的就是注释了 <BR> document.write("在页面显示的java script") //在页面显示一句话 <BR> </script><script> <BR> alert("在页面上显示警告对话框"); <BR> </script> Use of prompt() method: <script> <BR> confirm("在页面上显示确认对话框"); <BR> </script> <script> <BR> var con; <BR> con=confirm("你们喜欢这样的教程吗?"); <BR> if (con==true) alert("喜欢"); <BR> else alert("不喜欢"); <BR> </script> <script> <BR> var name,age; <BR> name=prompt("请问您的名字?"); <BR> alert(name); <BR> age=prompt("多大?"); <BR> alert(age); <BR> </script> It can not only display information, but also input information.

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template