Some knowledge about JavaScript as well as circular detailed _javascript techniques

Source: Internet
Author: User

Some of the knowledge points of javascript:

1. The five most popular browsers: Chrome,firefox,safari,ie,opera
2. Simplified version of how browsers work:
3.Js by Ecmajavascript;dom; BOM composition;
4.js is a weakly typed language (that is, it needs to be parsed by the viewer to know what type it is);

5.js is the scripting language (side parsing side execution);
6.script also in-line style, nested style and outer style.
The external style is generally written at the end of the body, because the front will load the JS code before doing other, affecting the user experience.
7. Synchronous and asynchronous
Sync: Executes one line at a row.
Asynchronous: Several pieces of content can be executed concurrently
such as: <script type= "Text/javascript" ></script>
Text is a property, followed by a property value, which is changed to the following property and property values the execution process changes:

Cycle
if (expression Boolean type) {
}

if (expression) {
}else if (expression) {
}else if (expression) {
}...else


Switch (n) {
Case "" Concrete value ":
code block;
Break
Case "" Concrete value ":
code block;
Break
Case "" Concrete value ":
code block;
Break
Default
code block;

}

var i= "1";
while (condition) {
declaring conditions;
i++;
}

do {
Execute the statement;
}while (condition);


for (Var i=0;i< "a number"; i++) {
declaring conditions;
}

"Some exercises"

1. Bubble sort: three times

var arr=[12,11,5,7,9,23];
for (Var i=0;i<arr.length-1;i++) {for
(var j=0;j<arr.length-1-i;j++) {
if (arr[j]>arr[j+1]) {
var temp=arr[j];
ARR[J]=ARR[J+1];
Arr[j+1]=temp
}
}} Console.log (arr);

2. Determine whether a number is prime (prime)

for (Var i=2;i<=100;i++) {for
(var j=2;j<=i;j++) {

if (i==j) {
console.log (i);
}
if (i%j==0) {break;}}}




3. Prompts the user to enter the class number, and enters each person's achievement, the sum and the average achievement, the highest and the lowest points

var user=parseint (Prompt ("Please enter class number");
var sum=0;
var Max=number.min_value;
var Min=number.max_value;
var arr=[];
for (Var i=0;i<user;i++) {
arr[arr.length]=parseint (prompt ("Please enter the first" + (i+1) + "classmate's score"));
Sum+=arr[i];
if (Max<arr[i]) {
max=arr[i];
}
if (Min>arr[i]) {
min=arr[i];
}
}
Console.log (sum);
Console.log (sum/arr.length);
Console.log (max);
Console.log (min);
Console.log (arr);

4. Implement multiplication Table (note: The page is added to the table)

document.write ("<table border= ' 1 ' >");
for (Var i=1;i<=9;i++) {
document.write ("<tr>");
for (Var j=1;j<=i;j++) {
document.write ("<td>");
document.write (i+ "*" +j+ "=" +i*j);
document.write ("</td>");
}
document.write ("</tr>");
}
document.write ("</table>");

5. Triangle

for (Var i=1;i<=4;i++) {for
(var j=1;j<=i;j++) {
document.write ("good");
}
document.write ("<br/>")
}

These are designed to judge the size value, SUM, create a new array and assign a value, the exchange of 2 elements in the array, the conversion of the basic data type parseint;

How to use <table>
<tr>
<td></td>
</tr>
</table>

Added to the loop medium issue, are very representative.

The above about JavaScript and some of the knowledge of the circular is a small series to share all the content, hope to give you a reference, but also hope that we support the cloud habitat community.

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.