JS Switch to Judge Trinocular operation while and attribute operation

Source: Internet
Author: User

Trinocular operations: such as var a = 10;var b= 12;c = a>b? a:b; If you set up execute a otherwise execute bvar ishide = true; If you use the IF Judgment statement as follows if (ishide) {box.style.display = "block" ;} else {Box.style.display = "none";} Trinocular operation instead of Ifbox.style.display = Ishide? " Block ":" None "; judging the condition? Set up execution statement: Execution statement is not established. Conditions of return: establishment of the results of the implementation of the conditions are not valid: the results of the implementation of the simplified version of If judgment  continue skip this cycle: Cannot write to the Trinocular operation column: for (var i=0;i<5;i++) {if (i==3) continue; Skip I= 3 This cycle does not carry out, others are still executed. }break: Terminates the entire loop; By default, only the next loop is terminated. If you want to terminate the other loops, you need to name the loop. Example: for (Var i=0;i<5;i++) {if (i==3) break; the entire loop is terminated when the loop executes to i=3. }name:for (Var i=0;i<5;i++) {for (Var j=0;j<5;j++) {Break name//Terminate two loops}}  object storage data, is an attribute of the object that exists: the object is a complex type of data, We can store any type of data in the object   The first: property operation 1 The one property operation is a set of dead values, and the variable cannot be used. Read Operation obj. property name write Operation obj. property name = attribute value; obj.key = val; key-value pair, such as var obj = {};obj.name = "Leo"; This notation is written for the first property names to be dead if you want to invoke the Obj.age = 40; Next Cons Ole.log (Obj.name);. Obj.gender = "female"; Console.log (OBJ.W);//Note that the first property operation is a value that is written dead, and you cannot use the variable OBJ.W to write the W property of obj.   Second property operation the second property operation is to do, receive a string, the string can exist in the variable, can be directly written obj[variable call] read operation obj["property name]obj[" property name "]= attribute value; obj[" Key "= Val; note the second type Var obj = {};obj[' name '] = "Leo";obj[' age ' = 40;obj[' gender '] = "female"; obj[' width '] = "180px"; obj[' height '] = "180px"; obj[' children '] = ["Daming", "Xiaoming", "sanming "];var w =" width ";//Console.log (obj[w]);//The second property operation, accepts a string, the string can exist in the variable, can be directly written obj[variable call];alert (" name "in obj); Obj returns true with the Name property, otherwise false to determine if there is a property in the object that returns True or FalseFor (var s in obj) {All properties that find obj will turn into Arr's property name//the same over in method will change the loop variable s into obj to Console.log (S,obj[s]); The name of the property that should be. If you want to use only the second name. The type of S is a string. } S is the property name Obj[s] is the property value of the corresponding property name.  for in can be used to loop objects and arrays cannot be used to loop a set of elements, for loops can only be used to loop arrays of array classes (a set of elements) that cannot be used to loop a set of objects.   ## #while语句 # # #起始值while (judging condition) {EXECUTE statement; self-increment;} # #switch # #switch (to be judged) {case: the content of judgment;// After the condition is established, the execution statement executes all code in the case, and only the break will end the execution of the statement; If you do not meet the break, you will be executed with all the code. Break;default://Above all the judgments are not valid} example switch (a) {case 10://when a = = 10;console.logo (";;;") statement is added breakbreak;//when a==10 cases 15 ://When A==15;console.logo ("PPPPP") Break;default://Above all judgments are not established} 

JS Switch to determine the trinocular operation while and property operation

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.