Some of JavaScript's points of knowledge:
1. The five most popular browsers: Chrome,firefox,safari,ie,opera
2. A simplified version of how the browser works:
3.Js by Ecmajavascript;dom; BOM composition;
4.js is a weakly typed language (that is, it requires the browser to parse to know what type);
5.js is the scripting language (side parsing side execution);
6.script is also in-line style, nested style, and inline style.
The outer style is usually written at the end of the body, because the JS code is loaded before the other, which affects the user experience.
7. Synchronous and asynchronous
Synchronization: A row of rows executes sequentially.
Async: Several pieces of content can be executed at the same time
such as: <script type= "Text/javascript" ></script>
Text is a property, followed by a property value, which is changed to the following properties and property values the execution process will change:
Cycle
if (expression Boolean type) {
}
if (expression) {
}else if (expression) {
}else if (expression) {
}...else
Switch (n) {
Case "Specific value":
code block;
Break
Case "Specific value":
code block;
Break
Case "Specific value":
code block;
Break
Default
code block;
}
var i= "1";
while (condition) {
Declaration conditions;
i++;
}
do {
Execute the statement;
}while (conditions);
for (Var i=0;i< "a number"; i++) {
Declaration 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 if 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. Prompt the user to enter the class number and enter each person's score, sum and average score, highest score and lowest score
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" + (i+1) + "Student'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 table is added on the page)
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. Triangles
for (Var i=1;i<=4;i++) {
for (Var j=1;j<=i;j++) {
document.write ("good");
}
document.write ("<br/>")
}
These inside are designed to determine the size value, SUM, create a new array and assign values, swap the 2 elements in the array, convert the data base type to parseint;
How to use <table>
<tr>
<td></td>
</tr>
</table>
Added to the cycle of medium problems, are very representative.
Some knowledge about JavaScript and the loop