Codefordream about JS Primary training

Source: Internet
Author: User

  The primary training here is relatively simple, almost all of the previous knowledge review.

For example, the output "Hello World", directly using Console.log () on the line. Comment Symbol, "//" can comment single line, shortcut key alt+/, "/* * * * *" can comment a large paragraph, shortcut key alt+shift+/. Then is to review the JS inside to the data type, learning this section of the time feel quite fruitful, because it is a comprehensive summary, can be clear at once the data in JS. There are two types of data in JavaScript-simple data and complex data. simple Data is only five kinds of undefined,null,boolean,number and string. There is only one type of complex data , object.

[1] Undefined: This value indicates that the variable does not contain a value.

If the return value of typeof (data) is the string ' undefined ', that is, the data type of the variable is undefined. That is, data does not contain a value. [Note: typeof is a JavaScript-provided operator that returns the data type of the data in parentheses after it is run. If typeof (' Hello ') returns the result is ' string ', then the type of ' Hello ' is a string. ]

[2] Null: This value indicates that the variable is empty.

If the return value of typeof (data) is the string ' null ', that is, the data type of the variable is null. That is, data is empty. The difference between undefined and Null is that the typeof (undefined) return value is ' undefined ', and the typeof (NULL) return value is the string ' object '.

[3] Boolean:true or False represents a Boolean value.

var data = true;

The typeof (data) return value is the string ' Boolean ', which means that the data type of the variable is a Boolean value.

[4] Number:javascript has only one numeric type. Numbers can be taken with decimal points or without. such as: 123 and 12.3

var data = 123;

The typeof (data) return value is the string ' number ', that is, the data type of the variable is numeric.

[5] Srting: As we said before, the string is the carrier of the character and must be surrounded by a pair of quotes. such as: ' Hello world! '

var data = ‘hello world!‘;

The typeof (data) return value is a string, that is, the data type of the variable is a string.

There are several types of data to be explained in detail, one can understand, it is worth noting, underfined and null, these two types I have learned not very clear, now has a clear to understand. Underfined simply means undefined stuff. For example, var A; Console.log (a) will output underfined.

About complex data object, which is the object, surrounded by curly braces. Inside the parentheses, the property is defined as a name:value of name and value pairs, which is what we often say about key-value pairs. The attributes are separated by commas.

For example:

var student={name:‘Tom‘, finish_work:true, id:123};
当然还有另一种特殊到对象-数组(arry)
The array is surrounded by square brackets. Inside the parentheses, the data is defined as a value in the form of a separate values. Data values are separated by commas. For example, an array of course names:
var courses = [ "Maths", "Chinese", "Biology, "Physics"];
关于运算符,有一个比较通用到三目运算,它的基本语法
:
 condition ? expr1 : expr2;

Condition the actual value is true, the EXPR1 is executed. Condition the actual value is False, the EXPR2 is executed.
About the function in JS, I used to often forget the back to (), such as Call Loadallitems () when I often write, var a =loadallitems, and the correct call should be the case, Var a =loadallitems.

JS Junior Training Almost all of these, brush up a lot of things that have been learned before, there is a warm and so know the new to the feeling ~

Codefordream about JS Primary training

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.