JavaScript Advanced (i)

Source: Internet
Author: User
Tags arithmetic operators ming

 ok Next, we comb the JS again and raise a level. As we all know, web front-end developers need to understand HTML and CSS, will only use HTML and CSS to create a beautiful page, but this is certainly not enough, because it is just a static page, we also need to use JavaScript to increase its behavior, to add dynamic effect to the page. First, what can JavaScript do? 1. Enhance the page dynamic effect (such as: drop-down menu, picture Carousel, information scrolling, etc.) 2. Achieve real-time, dynamic interaction between pages and users (e.g., user registration, login verification, etc.) what can you learn from the advanced text of JavaScript? In the JavaScript primer, we learned how to insert JS, output, and simple dom manipulation, and JavaScript advanced allows us to further understand JS variables, arrays, functions, grammars, objects, events, DOM operations, and make simple Web page dynamic effects. First, what is a variable? In the literal sense, the variable is the amount that can be changed. From a programmatic point of view, a variable is a memory used to store some/some of the values. We can think of variables as a box, a box for storing items that can be clothes, toys, fruits ... such as Then in order to distinguish these boxes, you can use Box1,box2 and other names to represent different boxes, Box1 is the name of the box (also the name of the variable) when we give the variable names can be arbitrarily taken, But there are some specifications to follow: 1. You must start with a letter, underscore, or dollar sign, followed by a letter, underscore, dollar sign, or number. As follows: Correct: mysum _mychar $numal Error: 6num//cannot be preceded by a number%sum//cannot be preceded by a special symbol other than $ or _ sum+num//opening middle cannot be used except $ or _ Special symbols other than 2. Variable names are case-sensitive, such as a and a are two different variables 3. JavaScript keywords or reserved words are not allowed as variable names         keyword break else new varcase Finally return voidcatch for switch whiledefault if throwdelete in Trydo instanceof typeof reserved words abstract enum int Shortboolea N Export interface Staticbyte extends long superchar final native Synchronizedclass float package throwsconst Goto Private TransIentdebugger mplements protected volatiledouble Import public  We're going to put things in a box, isn't it first to find the box, then in programming, the process is called declaring variables, looking for the action of the box, How TO: Declare variable syntax: var variable name, Var is the equivalent of a box, in JavaScript is a keyword (that is, reserved word), the role of the keyword is to declare the variable, and the "variable" to prepare the location (that is, memory). var mynum;//declares a variable mynum of course, we can find a box at a time, can also find more than one box at a time, so VAR can also declare more than one variable at a time, separated by a "," comma. var num1,num2; Note: Variables can also not be declared, directly used, but in order to standardize, need to first declare, after use. We think of variables as a box, boxes for storing items, and how do we store content in variables? We use the "=" equal sign to store the contents of the variable, such as: Var mynum=5;//declare the variable mynum and assign the value of this statement how to read it? Assigns a value of Mynum to the variable, with a value of 5. We can also write this: Var mynum;//declares the variable mynummynum=5;//to the variable mynum assignment Note: The function of the "=" Here is to assign a value to the variable, not the equals sign. The box can be loaded with clothes, toys, fruit and so on. In fact, a variable is an omnipotent container, and you can store anything in a variable, such as a value, a string, a Boolean, and so on. such as: Var num1=123;//123 is the value var num2= "123";//"123" is the string var num3=true;//boolean value True (True), False (false) where the NUM1 variable stores the content is numeric The num2 variable stores the contents of a string, the string requires a pair of quotation marks "", and the contents of the Nume3 variable store are Boolean values (True,false). The expression is then referred to. Expressions are similar to the definitions in mathematics, expressions are algebraic expressions that have certain values, and use operators to concatenate constants and variables together. An expression can contain constants or variables. such as: Num=num+1;num is the variable, = is the assignment, num+1 is the expression operator is used to specify a certain action in JavaScript symbol. (1) The operator looks at the following code: SUM=NUMA+NUMB, where "=" and "+" are operators. JavaScript also has many such operators, such as arithmetic operators, comparison operators, logical operators attention, attention, and then attention!!! The "=" operator is an assignment, not equal to! (2) the "+" operator arithmetic operator is mainly used to accomplish similar subtraction work,In JavaScript, "+" does not just represent addition, you can also connect two strings, such as: mystring= "Java" + "Script",//mystring's value "JavaScript" this string arithmetic operator except subtraction, There are also two very useful operators, from adding a "+ +", self-reducing one "-" first to see an example: the value of Mynum=10;mynum++;//mynum into the 11mynum--;//mynum value and back to the 10 above example, mynum++ So that the Mynum value on the original basis to increase 1,mynum--so that the mynum on the basis of subtracting 1, in fact, can also be written: mynum=mynum+1;//equivalent to mynum++mynum=mynum-1;//equivalent to mynum--and then said the comparison operator. We first said math problem, Xiao Ming exam 90 points, Xiao Red Test 95 points, ask who's score high? A: Because of 95>90, so the red exam results high, which is greater than > is the comparison operator. Xiao Hong exam results and Xiao Ming exam results is the operand, and is two operands. That is, two operands are compared by comparison operators, and the values are true (TRUE) and False (false) in JavaScript, so there are a lot of comparison operators, the meanings of these operators are as follows: operator description < Less than > greater than <= less than or equal to >= Greater than or equal to = = equals! = does not mean to look at the following example: Var a=5;//defines a variable, assigns a value of 5var b=9;//defines a B variable, assigns a value of 9document.write (A<b), and//a is less than the value of B? The result is true (true) document.write (a>=b);//a is greater than or equal to the value of B? The result is False (false) document.write (a!=b);//a is not equal to the value of B? The result is true (true) document.write (a==b);//a equals B value? The result is False (FALSE) PS: temporarily a bit of things, if you have free at night, will continue to update.

JavaScript Advanced (i)

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.