Some knowledge points of javascript:
1. Five commonly used browsers: chrome, firefox, Safari, ie, operator
2. Simplified version of how the browser works:
3.Js is composed of ECMAjavascript;DOM;BOM;
4.js is a weak-type language (that is, it requires the browser to parse it before knowing what type it is);
5.js is a scripting language (execute while parsing);
6.Script also branch styles, nested styles and outreach styles.
Outreach styles are generally written at the end of the body, because putting them in front will first load the js code and then do other things, which will affect the user experience.
7. Synchronous and asynchronous
Synchronization: execute one line by one.
Asynchronous: Several segments of content can be executed simultaneously
For example: <script type="text/javascript"></script>
Text is a property, followed by the property value. Here, the following property and property value will change the execution process:
"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){
Declare conditions;
i++;
}
do {
Execute statements;
}while(condition);
for(var i=0;i<"some number"; i++){
Declare 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 a prime number (prime number)
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 number of people in the class and enter each person's score, sum and average score, highest score and lowest score
var user=parseInt(prompt("Please enter the number of people in the class"));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 grade of "+(i+1)+"score"));sum+=arr[i];if(max<arr[i]){max=arr[i];}if(min>arr[i]){min=arr[i];}}console.log(sum);console.log(sum);console.log(sum/arr.length);console.log(max);console.log(min);console.log(min);console.log(arr);4. Implement the multiplication formula table (Note: the table is added to 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("</tr>");}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 determine the size value, sum, create a new array and assign values; converge the two elements in the array, and convert the basic data type parseInt;
How to use <table>
<tr>
<td></td>
</tr>
</table>
Adding to the loop problem is very representative.
The above knowledge and detailed explanation of JavaScript are all the content I share with you. I hope you can give you a reference and I hope you can support Wulin.com more.