Home > Article > Web Front-end > Js basic learning materials_basic knowledge
1. To prevent problems with browsers that do not support js, you can handle the JS code like this
2. JS placement location:
header: Make sure the script is loaded when it is called
body: the page is loaded When entering, call the <script> external js file: does not contain the <BR> tag <script src = "xxx.js"> usage: ...<BR> <BR> 3. Comment <BR> single line: // <BR> more Line: /*.....*/ <BR>4. The congruent symbol indicates that the types and values are equal <BR>5. Three prompt boxes <BR>Warning: alert("alert"); <BR>Confirm: confirm("confirm"); <BR>Prompt: prompt("prompt","default value"); <BR>6. for in statement<BR>for (variable in object) <BR>{ <BR>Execute code here<BR>} <BR>7. Regular expression<BR>test() method: Retrieve the specified value in the string, return True if there is one, otherwise False <BR>var patt1=new RegExp( "e"); <BR>document.write(patt1.test("The best things in life are free")); <BR>exec() method: retrieve the specified value in the character, and return the found value if there is one , otherwise return null <BR>var patt1=new RegExp("e"); <BR>document.write(patt1.exec("The best things in life are free")); <script type="text/javascript"> <BR><!-- <BR>document.write("Hello World!"); <BR>//--> <BR></script>compile() method: use For changing the search mode and adding or removing the second parameter