JavaScript Great God Practice Note (2)

Source: Internet
Author: User

Good reader friends, before I have a general understanding of the role of JavaScript and some basic function declaration and variable declaration, today we go on to the previous content, we will look at the logic of javscript (positive order, Branch, loop) and some simple operators

Let's talk about some simple operator operators

+ PLUS sign: 1. Used to calculate two digits plus and 2. Used to stitch two strings together
-minus: 1. Used to calculate the difference between two numbers, 2. Used in front of a number to identify a negative
* Multiplication sign: Used to calculate the product of multiplying two numbers
/Division sign: Used to calculate dividend divided by divisor, the resulting quotient
Percent gain: the remainder to calculate the dividend divided by the divisor (here the calculation is divisible, and the remainder after division is obtained)
= Assignment: Used to assign a value (which can be an object, function, number, String, Boolean) to a variable

Here, we can clearly see the operator to show the results of the operation, subtraction I do not have to repeat, I believe that everyone's calculation should be better than me, because I just graduated from high school, a little more to say is to take the rest of the operation, see above example 5%2 take more than 1, is this calculation, 5÷ 2 = 2 ... 1, the second grade in the primary school should have seen the calculation, the divisor ÷ divisor = quotient ... Remainder, the remainder is the result of the take-up operation, but also is the equal sign that has been mentioned yesterday, is used to assign the value of the var temp = value; We use the VAR keyword to declare the variable, with = to give you a value, the type of the value can be object, function, number, String, Boolean, the previous has been told, what the function is, is a function to declare a functional body, that is function, the number needless to say, string, A string of strings enclosed in quotation marks, a Boolean value, is a type of only two values, true and false, without a third.

Then let's look at the various values.

        //here we give an empty object (NULL)        varTemp_1 =NULL; //Here we give a function        varTemp_2 =function() {Console.log ("Write Something");        }; //here we give a string        varTemp_3 = "My name is Mrdream"; //Here we give a Boolean value        varTemp_4 =true; 

These basic operations, everyone should be at a glance, hope that the reader friends see these basic things, now do not worry, now we are still in the introductory introduction to explain the stage, so these basic things, we must understand, to the back of the article, I will also speak more things, otherwise, the foundation does not play well, behind, When I tell you something that you think is going to be awesome, if you can just copy the code and use it, you don't have the means to write something you want.


Let's take a closer look at what it looks like after a small upgrade of the operator. (Note: For now, I'm just talking about some basic operators, and some special operators, which I'll explain later in some applications, and then understand more deeply.)

+ = Plus: First add two operands, then assign the added value to the first action object
-= minus: Subtract two operands first, then assign the added value to the first action object
*=: First multiply the two operands, and then assign the added value to the first action object
/=: Divide the two operands first, then assign the added value to the first operand.
%=: First the two operands to take the remainder operation, and then assign the added value to the first action object

And then some simple comparison-judging operators

= = equals: Determines whether the objects on both sides of the operator are equal
= = = Absolute equals: Determines whether the objects on both sides of the operator are absolutely equal
!== is definitely not equal to: Determines whether the objects on both sides of the operator are absolutely unequal
! = does not equal: Determines whether the objects on either side of the operator are unequal
|| or (OR): first determine whether the object on the left and right side of the operator is a "non-empty object or a non-undefined object", if all two are, it returns to a value, if a value is not, return is not that value
&& and (and): first determine whether the object on both sides of the operator is a "non-empty object or a non-undefined object", if neither, returns the right value, if there is a value, returns the left value
! Inverse (non): Converts a value to a Boolean value and then takes the inverse

(Note: Mentioned here or, and, take the inverse operator, I use the general understanding of logic to speak, in fact, the internal operation is related to binary or non-operation results, we speak of the binary system when the time to say) below we look at some examples

The following is a little or non-operation, understanding is a little more difficult

Look at the picture, a, because the operator left undefined object, so return to the right of the value, B, because the left is empty object, so return to the right value, C, because the left has a real value number 123, so return to 123;d because the left is the real value of the number-1, so return to the left value. Add one: Number 0 is also a special value, if the left side is 0, then the right value will be returned.

The function of a summary or operator: It is used to look at whether the left and right sides of the operator are undefined values, null values, 0,false, if the left side is the values, return the value to the left, if the left is not the values of these types, return the value to the Ieft.

Then the operation

Still look at the picture, a: left and right are undefined objects and empty objects, return to the left of the value, B, left is empty object, so return to the left, C: Right is undefined object, so return to the wrong side, D: Same as C, E: Both are non-empty objects, the left side of the Boolean value is true, ; F is in the same place as E; G: Because the left side is 0, with undefined objects, empty objects, and false siblings, the left value is returned.

The last one is non-operational

Continue to look at the diagram, a: The operation is 0 false null undefined value, the return, obtained the Boolean value of the true;b: all the real value is reversed, the obtained primary is the Boolean value false. We can conclude that the inverse obtained is the boolean value, the actual value of the inverse is correct, the actual value of the inverse is wrong.

Well, today to write here, summed up, today, in fact, also said some very basic operators, but the number of operators a bit more, so it is written so, before it is finished, there are some special operators, we will say, as long as a little progress every day, the achievement of a generation of the great God is not a dream.

JavaScript Great God Practice Note (2)

Related Article

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.