The switch statement is used to execute different actions based on different conditions.
JavaScript switch statement
The switch statement is used to execute different actions based on different conditions.
JavaScript switch statement
= "Peking";
Form.zipcode.value = "10000";
Therefore, we should avoid using the WITH statement as much as possible in future efficient code development.Tested:var a =123;var B = {A:321};With (b) {console.log (a); //321} var a = 123; var B = {}; This removes the A attribute from B with (b) { console.log (a); //123} in JavaScript, a function is also an object, and in fact, everything in
:
Copy Code code as follows:
How to refresh the page for another frame:
Copy Code code as follows:
If you want to close the window or refresh when you want to open windows, call the following statement in
Refresh when opening window:
Copy Code code as follows:
Refresh at shutdown:
Copy Code code as follows:
Copy Code code as follows:
JS closes the current page,
The condition declaration in JavaScript is used to complete the action under different conditions.
Condition Statement
When writing code, you often need to perform different behaviors according to different conditions. You can use the condition declaration in the code to complete this task.
In JavaScript, we can use the following conditional declarations:
If
the transfer of control to the calling function to continue execution.
Extension Description:
The general application of the return statement is not special, and the most notable is the use of return false. The event handler function returns false to organize the occurrence of the default event.
The code example is as follows:
Clicking on a link will cause the OnClick event to be clicked, and the default action is to link to the link
In JavaScript try...catch ... Statement, we learned how to catch a system-thrown error. JavaScript allows us to customize the error and throw the error message.Throw statementThe throw statement allows us to create custom errors.The correct technical term is: Create or throw an exception (exception).If you use throw wi
The usage of the switch statement in JavaScript is described in detail.
You can use multiple if... else if statements, such as the previous chapter, to execute multiple branches. However, this is not always the best solution, especially when all branches depend on the value of a single variable.
Starting with JavaScript1.2, you can use it to handle this situation. Using a switch
This article describes how to use a command object to replace the switch statement. The switch statement is forbidden in the JS specification. Using the command object can perfectly solve this problem, if you need a friend, you can refer to someone who once said that there is no such program .. else, of course, switch is not as good as if .. else. Switch is forbidden in JS specifications.
The command objec
This article starts with the blog Park and continues to update the front-end series on GitHub. Follow me on GitHub, get started and go to the advanced front.
The following is the text.
If statement of the most basic if statementStructure of the IF statement: (format) if{ // 条件为真时,做的事情 }else{ // 条件为假时,做的事情 }If statements also become "SELECT
When writing code, you often need to perform different behaviors according to different conditions. You can use conditional statements in the code to complete this task.
In JavaScript, we can use the following conditional statements:
If statement
Run the code when a specified condition is set.
If... else statement
Execute the c
Describes how to use the for... in statement in JavaScript.
This article mainly introduces how to use the for... in statement in JavaScript. It is the basic knowledge in JS beginners. for more information, see
Here is another loop supported by JavaScript. It is called a for.
This article translates the JavaScript Tutorial playlist of up master Kudvenkat on YouTubeSOURCE Address here:https://www.youtube.com/watch?v=PMsVM7rjupUlist=PL6n9fhu94yhUA99nOsJkKXBqokT3MBK0bWhen should we use the Swtich statementTo enhance readability, we can replace the IF-ELSE-IF statement with a switch statementNotice that the following code has multiple IF-ELSE-IF statementsvar userinput = number (Pro
Conditional statementsOften when writing code, you always need to perform different actions for different decisions. You can use conditional statements in your code to accomplish this task.In JavaScript, we can use the following conditional statements:
If statement-use this statement to execute code only if the specified condition is true
If...else
Read a lot of JavaScript strict mode, which has said "Disable with statement", previously seen this is riding on the flowers, around the area, because usually rarely used this statement, the ban can not help to their relationship is not very big. Today, I can't help wondering why the "strict mode" doesn't allow the WITH state
I sorted out the "common JavaScript statement set (1)" last time and thought it was incomplete. Today I read a collection from someone else, so I did it myself.
Added some frequently-used JavaScript statement sets (2 )".
The following lists some commonly used Javascript. You
Syntax format
With (object instance){code block}
Sometimes, I'm in a program code, many times you need to use an object's properties or methods, as before, are passed: Object. Property or object. method to obtain the object's properties and methods in such a way that it is a bit troublesome to learn the WITH statement, you can do this in a way similar to the following:
With (Objinstance){var str = attribute 1;.....}
Remove the trouble of writing o
This article mainly introduces the ForIn statement usage In Javascript. examples show how to use the ForIn statement to traverse arrays In javascript. For more information, see the example In this article. Share it with you for your reference. The details are as follows:
For In
For... in statement
An object. Execute one or more statements for each element of an object or an array.
Format:
Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->
For (variable in Statement){Execution statement}
Instance:
Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.C
Using a unique VAR statement at the top of a function is a recommended pattern, and the benefits are:1, you can find all the variables in the same place.2. Avoid the logic errors generated by using the variable before the variable declaration.JavaScript allows you to write any number of VAR statements anywhere in the function, but they behave like declaring variables at the top of the function body, which is called "declaration ahead," which can cause
A custom new page for a normal list of SharePoint 2013, where I added a few lines of JavaScript code and the page won't open. :Really a word, Friendship Page said can not open ah. Then slowly compared to the discovery because there is a for loop in JavaScript, when the for loop is removed, the page can open normally, and when the for loop is added, the page will not open.Reason: The list of custom pages is
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.