JavaScript Summary (3)

Source: Internet
Author: User

The 3rd chapter gets the user's input

The prompt function is used to get the user's input. The function has two parameters//the function will "return the user's input as a string" Input 1 returns "1". String
Number, the first is the prompt that is displayed when the input is requested, and the other is the default value of the input. The function will use the
The user's input is returned as a string. The syntax is:
Strvariable=prompt ("Here is the prompt message displayed", "Here is the default input value");
The returned user input is saved in the variable strvariable.

3.2.2 What do you mean operator
An operator is a symbol that operates on the data, which expresses the actions to be performed on the data. Table 3.1 is
A list and description of all the operators in JavaScript.

[]: Brackets are used only to indicate the following table in the array

Ternary conditional operators are more complex, here is an example to explain. Ternary operator, which is considered to be used when the case is 2 choices, if the condition A is satisfied, which is executed, and if the condition B is satisfied, which
X=prompt ("Please enter a positive integer", "10");
Y=x>5? (x-5):(x*2);
alert (y);

S_str= "ABCDEFG". substring (1,4);
The result of the run, the content of S_str is "BCD". Note: The difference from the C # split: (1) from index=1 to End (1,4) 4 lengths starting from 1

JavaScript Summary (3)

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.