(7) JavaScript learning notes-operators (continued)

Source: Internet
Author: User

I. assignment operators with operations

1. + = perform addition and value assignment operations

 
Total + = sales_tax; // equivalent to total = total + sales_tax;

Ii. Conditional Operators
1. Ternary Operators

 
Greeting = "hello" + (username! = NULL? Username: "there"); // equivalent to greeting = "hello"; if (username! = NULL) greeting + = username; else greeting + = "there ";

Iii. typeof Operator
1. Before an operation number, the returned value is a string, indicating the type of the Operation number;

2. the number returns "Number", the string returns "string", the Boolean Value Returns "Boolean", the object, array, and null return "object", and the function returns "function ", undefined is returned"

Iv. array and Object Access Operators
1. Use [] to access the elements of an array and use. To access the elements of an object;

2. the object on the left and an identifier (property name) On the right must be the direct volume name of the property or method of the object, and the type does not need to be specified.

 
Document. lastmodified; navigator. appname; frame [0]. length; document. Write ("Hello World ");

3. If [] is an array on the left, the right must be an integer.

Frames [1]; document. Forms [I + J]; document. Forms [I]. elements [J ++];

4. If [] is an object on the left, it should be a string expression on the right, which specifies an attribute of the object;

 
Document ["lastmodified"]; frames [0] ['length']; data ["Val" + I];

 

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.