The difference between substring and substr
The substring () method is used to extract the character of a string intermediary between two specified subscripts.
Stringobject.substring (Start,stop)
Example:
<script type= "Text/javascript" >var str= "Hello world!" document.write ( str.substring(3,7) ) </script>
Results:
Lo W
The substr () method extracts a specified number of characters from the start subscript in a string.
Stringobject.substr (Start,length)
Example:
<script type= "Text/javascript" >var str= "Hello world!" document.write ( str.substr(3) ) </script>
Results:
Lo world!
--------------Split Line--------------------------
The difference between Getelementsbyname and getElementById
Document.getelementsbyname gets an array, and document.getElementById gets the unique element object, to get a particular element object through Document.getelementsbyname, and to add subscript: do Cument.getelementsbyname ("Text1") [0] Gets the first element object with the name value of Text1.
jquery in HTML (), text (), Val () difference
HTML is where you can add tags like <a></a>, <p></p>, etc.
Text can only be written if the above mark is written, it will be printed in text form.
Val is a property and only the object with that property can call
The return in JS; return False;return true;
Retrun true; Returns the correct processing result.
return false; Branch error processing result, terminate processing.
return; Returns control to the page.
See an example:
<script type= "Text/javascript" >
function A () {
if (true)
return false;
}
Function B () {
Console.log ('-----------');
}
function Test () {
A ();
b ();
}
Test ();
</script>
The result of this example is:
-----------
Call the A () function in the test () function, where return false is equivalent to the return value for the test () function. The test () function cannot be prevented from executing.
If you change to:
<script type= "Text/javascript" >
function A () {
if (true)
return false;
}
Function B () {
Console.log ('-----------');
}
function Test () {
return a ();
b ();
}
Test ();
</script>
The result is:
Empty
Return a () here, which prevents the program from running.
It's good to use this example to understand Retun.
Above is a number of basic JS knowledge, is also the daily common knowledge, and very easy to mistake, so write down, from time to read.
JavaScript Common Sense