This article illustrates some of the techniques commonly used by JavaScript beginners. Share for everyone to use for reference. Specifically as follows:
One, javascript program storage location
*.js file inside
Second, the standard format
In HTML
Placed between the
Some of the common JS method or other to avoid causing code dupli
Each language has its own special place, for JavaScript, using VAR can declare any type of variable, the script language seems simple, but want to write elegant code is need to accumulate experience. This article makes a list of seven details that JavaScript beginners should pay attention to and share with you.(1) Simplified codeJavaScript defines objects and arr
In the previous
Programming Language In the ranking, we once introduced the Javascript language, just
Article As stated in, JavaScript is not only the most dynamic scripting language, but also one of the most useful programming languages. Because most browsers are compatible with it, you can use it in these browsers. Javascript is accepted quite quickly because
BKJIA's August 24 E-headlines: In the previous programming language rankings, we once introduced the JavaScript language that is just getting started. As stated in the article, JavaScript is not only the most dynamic scripting language, or one of the most useful programming languages. Because most browsers are compatible with it, you can use it in these browsers. JavaSc
!
Closure 3:
You can also use closures to access function parameters.
function f(arg) {var n = function(){return arg; }; arg++;return n;}
If:
var m = f(123);m();
Result 124
In this case, the anonymous function returned by f goes through two new steps. n is given first and then m is assigned to the outside, but the essence is not changed.Definition timeThe parameter of the parent function is returned.
Closure 4:
var getValue, setValue;function() {var secret = 0; getValue = function(){return s
Javascript basics, basics of photography for beginners
Javascript Introduction
Javascript has three important components: ECMAScript, DOM, and BOM.
ECMAScript is the core language defined by ECMA specifications. In fact, this language does not contain input and output definitions. The ECMA Specification defines only
Note: I edited the original text, some words to mark the color, easy to read. Originally prepared to translate, but feel that the article is simple and understandable, and the original written very well, so it is not shortcoming. Hopefully it will be helpful for JavaScript beginners. You can follow the author to do the sample code, and when you finish reading the article, you will be able to master the basi
All languages have their own special features. For JavaScript, using var can declare any type of variables. This script language looks very simple, however, if you want to write elegant code, you need to constantly accumulate experience. Next, we will introduce that Beginners should pay attention to the special features of various languages. For JavaScript, using
result:DddddDddddAaa4.3. Scope of VariablesThe scope of a variable is the region of the variable defined in the program. The scope of a global variable is global, that is, it can be called everywhere in JAVASCRIPT code. The variables and function parameters declared in the function are defined only in the function body. They are local variables and the scope is local.In the function body, local variables take precedence over global variables with the
result:DddddDddddAaa4.3. Scope of VariablesThe scope of a variable is the region of the variable defined in the program. The scope of a global variable is global, that is, it can be called everywhere in JAVASCRIPT code. The variables and function parameters declared in the function are defined only in the function body. They are local variables and the scope is local.In the function body, local variables take precedence over global variables with the
Every language has its special place, for JavaScript, the use of Var can declare any type of variable, the scripting language seems very simple, but want to write elegant code is need to accumulate experience. This article provides a list of seven details that JavaScript beginners should pay attention to, and share them with you.
(1) Simplify the code
---------
; One returnTotal ; A } - //This replaces the above, the global and local names, and the local affect the global variables7.New and constructorsWhen we add new, we construct the object, and no new is a call to the normal function.11//when you want to declare several task objects, you may be able to declare a22varNUM1 = {Name:tim, age:20, ... };3 varnum2 = {Name:may, age:19, ... };4 varnum3 = {Name:ken, age:26, ... };5 ... ...6 //one by one statements when the number of a lot, it will
Each language has a special place. For JavaScript, using var can declare any type of variables. This script language looks very simple, however, to write elegant code, you need to constantly accumulate experience. This article lists seven details that JavaScript Beginners should pay attention. Nbsp; SyntaxHighlighter
Each language has a special place. For
Because most browsers are compatible with it, you can use it in these browsers. Javascript is accepted quite quickly because it is so simple and widely used. Many
Program In the past, JavaScript was often regarded as a "Toy language". However, Ajax entered the market and showed the opposite side. It showed completely different capabilities and functions for JavaScript
All languages have their own special features. For JavaScript, using var can declare any type of variables. This script language looks very simple, however, to write elegant code, you need to constantly accumulate experience. This article lists seven details that JavaScript Beginners should pay attention.
(1) simplified code
------------------------------------
variable is used only within a function. For example:
[Ctrl + A All SELECT Note: If the need to introduce external JS need to refresh to perform]
Run Result:
Ddddd
Ddddd
Aaa
4.3. Scope of variables
The scope of a variable is the region in the program that defines the variable. The scope of global variables is global, that is, it can be invoked everywhere in JavaScript code. The arguments for variables and functions declared
the configuration object, such as css id, class name, and language.3. Return this object as a public attribute so that others can rewrite it.(7) code compatibilityCompatibility is easy for beginners to ignore. Generally, Javascript is tested in a fixed browser, and this browser is probably IE, which is very fatal, this is because IE currently has the worst standard support among several mainstream browsers
In the previous list of programming languages, we introduced the JavaScript language of the impending regularization, as illustrated in the article, that JavaScript is not only the most dynamic scripting language, but also one of the most useful programming languages. Because the vast majority of browsers are compatible with it, you can use it in these browsers. JavaScr
inner ghost and returns the value of B ......
Now, everyone is feeling a little bit.
Closure 2:
The Code is as follows:
Var n;Function f (){Var B = "B ";N = function (){Return B;}}
What if I call f at this time? Then a global range Function of n is generated, but it can access the inside of f and returns the value of B, which is similar to the above!
Closure 3:
You can also use closures to access function parameters.
The Code is as follows:
Function f (arg ){Var n = function (){Return ar
JavaScript beginners: 004-JS annotation Writing Method and basic operators, 004jsJS commentsAdding comments in JS is similar to writing C # code. There are two types: // and.Single line commentUse a double slashFor example,
Multi-line comment
Use/* content */
For example,
Basic operators of JS
The basic operators in JavaScript are basically the same as those i
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.