November 25, 2016, using the morning time to learn JavaScript data types and variables, the afternoon should go to the library to bubble books.
After reading this chapter of the variable , I may not be able to finish the day, so I'll use the morning and evening nine o'clock to come back. Adjust the mentality, do not ask for speed, just quality, learn can, maybe I am the next js big God/laugh/laugh/Steal laughter
2.1 and get the following small example:
Code Explanation:
2.1.1 Var myfirstvariable; At this time the value of the variable is undefined, for the computer, the variable declaration merely indicates the existence of the variable, and does not hold any actual data in it, but underfined is indeed a basic value in JS, You can also use this value to compare. For example, you can use the undefined value to check whether a variable contains an actual value, and if it does not contain any actual value, its value is undefined
2.1.2 Myfirstvariable = "Hello"; literal value: The actual data, not the values obtained from other variables or after calculation. In any place where numeric literals or string literals are used, you can replace them with a variable that contains a numeric value or a string.
2.1.3 myfirstvariable = 54321;
2.2 Assigning values to variables with the values of other variables
Copy of data: As a general rule, basic data types, such as String types and numeric types, replicate a separate copy of the data as they are assigned.
Other complex data types, when copied, refer to the same object instead of copying an object copy.
2.3 Setting up the browser to display error messages
Allows the browser to display errors in the code itself
In Firefox
2.4 Working with data-basic operations for calculating numeric values and strings
The three alert in the code is loaded with a value of 1.5.
In most cases of JS, variables are used to calculate. Even if you calculate with a variable, a value, and a variable, and then save the result in another variable. For the use of literal calculations such as 15/10, it is best to first calculate the value of the expression and write it directly into the code. Instead of letting JS calculate the value of an expression 5/10, write 1.5 directly in the code. This will not aggravate the burden of JS, making it more and more slow speed. This benefit can also make your code more readable. We can also assign the expression to a variable and use the variable name to express the value, for example, per kilogram of units assigned to the variable priceperkg, so that the code will be easier to read and understand.
2.5 self-increment and decrement operators
The following is a special understanding
Operator:--、 + +, + =
Precedence of the 2.6 operator
Get the following small code
Code: Degfahren is not assigned, but instead prompts the user to enter a value using the prompt () function. The use method is similar to the alert () function but contains a text box for the user to enter a numeric value, in addition to prompting the user for information. The values entered by the user are saved in the variable Degfahren. The return value of the prompt () function is a string that can be used as a value, and JS will implicitly convert it to the corresponding value.
Prompt () requires two parameters: 1, the string to display, usually to remind the user of the information entered
2. When the prompt dialog box pops up, enter the default values that are included in the box
Two parameters are separated by commas and given in the order specified. If you do not need to set the default value for the input box when the prompt dialog box pops up, set the second parameter to an empty string "".
2.7 Basic manipulation of strings
Learning to get started with JavaScript (ii)