No nonsense JavaScript tutorials (complete) 1th/4 page _javascript Tips

Source: Internet
Author: User
"Programmer" No. 2008.09 has an article called "No Nonsense Erlang", this makes me think of a lot of things like "no nonsense C", "No Nonsense book review" of this kind of article, also thought of JavaScript can not have a "no nonsense", so decided to open an article to write this. Related to this decision, but also because of the other reason: Many readers think that my "JavaScript language Essence and Programming practice" read hard, so I always want to write a simple reading. Simply, write the simplest one this time.

Make a statement: If you just want to see something complicated, don't read this article.
first, JavaScript is actually a procedural
The JavaScript that goes back to the 1.0 era is actually a procedural one. It has only two basic features, one that can be placed directly in the HTML of the page
tag to take over the event, for example:
Copy Code code as follows:

<input type= "button" onclick= "alert (' Hello ')" >

The second is to support a Simple Object Builder (function). In fact, the constructor of this era is more appropriate than the initialization function, it should
Write this:
Copy Code code as follows:

function MyObject () {
this.xxx = ' ... ';
this.yyy = ' ... ';
}
obj = new MyObject ();

So, it is not wrong for early JavaScript to undoubtedly recite the moniker "object-based Procedural scripting language". Apart from
With the above two features, JavaScript has some general scripting language properties, such as:
-The entire. js file is loaded into the execution environment (such as a Web browser) one at a time, and begins to be executed on a line after parsing.
-In the above parsing cycle, the (named) function and variables declared with "Var" are processed in a table of identifiers so that script code can be used;
-Executes from a global code line or function call, and the code that is not executed throughout the process is not incorrectly checked (except for the syntax check error in the first step).
Also has the nature of the usual procedural language, for example:
-There are if/for/while/switch and other statements;
-Use function to declare functions, using "(..)" To declare its form parameter table, and to represent function calls and arguments;
-Similar to the basic syntax for C, including the use of "{..}" To represent a block of code, and the use of "!=" and other operational symbols;
-An object manipulation operator, similar to the Java language, "." Number, and the basic concepts of attributes and methods.
Well, now that you see a basic JavaScript language, its code has only functions like C and statement lines that support very simple faces
Programming to Objects. OK, this is almost all of javascript ... Well...... All the basic concepts of grammar. If you've ever used a door even
A little bit of a beginner's programming language, you'll think JavaScript is actually quite simple.
Yes, "write a function, then call it," that's simple. For example:
function Hi () {
Alert (' Hello, world. ');
}
Hi ();
two, slightly more complex is the data type
JavaScript has six basic types of data, divided into two categories. A class is a value type, i.e. Undefined,string, number and Boolean;
is a reference type, that is, function and object. Detects what type of data x is, and can simply use "typeof X" to return a string.
Value types and reference types are used in other high-level languages to distinguish between a value or a reference during an access procedure. Simply put, in the following function
In
function foo (X) {
}
Whether X is passing in the value itself, or a reference to the value (which you can imagine as a pointer), indicates what type X is. Different from other languages
Yes, JavaScript does not add an indicator to the call entry to describe the method of passing the value, for example:
function foo (var X) {
In the general high-level language, VAR indicates that the reference to the variable x is always passed in
}
Instead, it is simple for the script engine to decide how to pass the value based on the data type of the actual x passed in. For example:
function foo (X) {
...
}
Foo (' 123 '); <-string ' 123 ' value
Foo (aobj); <-Aobj is an object reference
The key to this process is that the JavaScript type system is concise enough. Six basic types include three philosophical concepts: the ability to perform
An object or a non object that cannot be executed, has (value) or none (value). Clearly, it is not easy to understand this philosophical idea, because a more complex layer
, self-contained logic is: A function is also an object, a value is also an object, no value is also a value.
This is all of the JavaScript type system. If you want to use it simply, remember that the following is enough:
-string, Number, Boolean three simple value types are used to pass to the Web page display;
-object is used to hold other object, funtion, or above simple value types, and to use '. ' Operations are found by an attribute name;
-undefined is used to detect the effective and invalid data;
The-function is used for execution.
Of course, if you're going to be a thinker or a linguist, think about the philosophical proposition above, and I won't stop you.
Three, can use the nose to figure out is the direct quantity
Maybe a lot of people don't understand the direct volume statement in JavaScript, but it's really simple. Since most of our advanced languages are
Constant declarations are supported, and even the most primitive assembly language supports immediate values-for example:
In C
#define ABYTE 256
In Delphi
Const
Abyte = 256
; In ASM
mov ah, 256
Current 1/4 page 1234 Next read the full text
Related Article

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.