Home >Web Front-end >JS Tutorial >Mastering Javascript Series - Javascript Basics_Javascript Skills

Mastering Javascript Series - Javascript Basics_Javascript Skills

WBOY
WBOYOriginal
2016-05-16 18:06:071074browse

Basic concepts of javascrpit:
1) Case sensitivity Just like JAVA, variables, functions, operators and everything else in JS are case sensitive. For example: the variables MyTag and MYTAG are two different variables .
2) Weak type change. So the so-called weakly typed variable refers to the fact that the variables in JS have no specific type, unlike C. Only use "var" to define a variable, and it can be initialized to any value, so that the type of data stored in the variable can be changed at will, which is not recommended;
Example: var age=25;
var myName="zhangsan";

3) The semicolon at the end of each line is optional;
Example:
var a=2
var b=3;
Note: If there is no semicolon, JS will default to the end of this line of code as the end of the statement;
4) Brackets are used for code blocks, and code blocks represent a series of codes that are executed in sequence. All are enclosed in JS curly braces "{}"
Example:
if(myName=="aa")
{
var age=67;
alert(age);
}
5) The way to comment is the same as C, C#, JAVA
//Single-line comments
/*
Multi-line comments
*/
For HTML pages , JS code is included between the <SCRIPT> and </SCRIPT> tags, and external JS documents can also be called through the SRC attribute in <SCRIPT>; <br> Example of a complete HTML page containing a JS document structure<br></p> <div class="codetitle"> <span><a style="CURSOR: pointer" data="79587" class="copybut" id="copybut79587" onclick="doCopy('code79587')"><u>Copy code</u></a></span> The code is as follows:</div> <div class="codebody" id="code79587"> <br><html> <br><head> <br> <title>The complete HTML page contains JS document structure</title> <br><script language="javascript"> <br>var myName="zhangsan"; <br>document.write(myName); <br></script>


Text



Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:Implement code_jquery with Juery web tabNext article:Implement code_jquery with Juery web tab

Related articles

See more