Page 1/4 of the no-nonsense JavaScript tutorial (Full Set)

Source: Internet
Author: User

There is an article named "no nonsense ErLang" in the 2008.09 issue of programmer, which reminds me of many articles such as "no nonsense C" and "no nonsense book reviews, I also thought that JavaScript does not have a "no nonsense", so I decided to write this article. This decision is related to another reason: many readers think that I have been reading the essence of JavaScript language and programming practices, so I have always wanted to write a simple reader. Simply put, this is the simplest one.

Declaration: If you only want to read complicated things, do not read this article.
I. JavaScript was originally a procedural
JavaScript, which dates back to the 1.0 age, is actually a process. There are only two basic features. One is the HTML
Tag to take over the event, for example:
Copy codeThe Code is as follows:
<Input type = "button" onclick = "alert ('hello')">

The second option is to support a simple object constructor (function ). In fact, the constructor in this era is better than the initialization function. It should
Write as follows:
Copy codeThe Code is as follows:
Function MyObject (){
This. xxx = '...';
This. yyy = '...';
}
Obj = new MyObject ();

Therefore, early JavaScript was undoubtedly carrying the name "Object-based procedural scripting language. Besides
For the above two features, JavaScript has the nature of some general scripting languages, such:
-The entire. js file is loaded to the execution environment (for example, a WEB browser) at a time. After a syntax analysis, the file is executed row by row;
-During the preceding syntax analysis period, (named) Functions and variables declared with "var" are pre-processed in an identifier table for use by script code;
-From the execution of global code lines or function calls, the code that cannot be executed in the whole process is not found in the error (except for the syntax check in step 1 ).
It also has the nature of common procedural languages, such:
-Statements such as if/for/while/switch are available;
-Declare a function with function, and use "(...)" to declare its form parameter table, as well as to indicate function call and parameter passing;
-Similar to the basic syntax of C language, including the use of "{...}" to represent the code block, and the use "! = "And other operators;
-A basic concept similar to the object operation operator "." in Java, as well as attributes and methods.
Now you see a basic JavaScript language. Its Code only has functions and statement lines like C, and supports a very simple area.
Program to an object. Okay, this is almost all about JavaScript ...... Hmm ...... All basic syntax concepts. If you use one
If you get started with a little bit of programming language, you will think JavaScript is actually quite simple.
Yes, "Write a function and call it" is that simple. For example:
Function hi (){
Alert ('hello, world .');
}
Hi ();
2. The data type is slightly more complex.
JavaScript has six basic data types. One type is the value type, that is, undefined, string, number, and boolean.
Is the reference type, that is, function and object. To check the type of data X, you can simply use "typeof X" to return a string.
In other advanced languages, the value type differs from the reference type by using "pass value or reference during access. Simply put, in the following function
Medium:
Function foo (X ){
}
X indicates the value itself or a reference pointing to the value (you can think of it as a pointer), indicating the type of X. Different from other languages
Yes. JavaScript does not add a indicator to the call entry to demonstrate the method of explicitly passing values. For example:
Function foo (var X ){
// In general advanced languages, var indicates that the reference of variable X is always input.
}
Instead, the script engine determines how to pass the Value Based on the Data Type of X actually passed in. For example:
Function foo (X ){
...
}
Foo ('20140901'); // <-string '20160901' Value
Foo (aObj); // <-aObj is an object reference
The key to such processing is that the JavaScript type system is concise enough. The six basic types include three philosophical concepts: executable
And non-executable; object or non-object; has (value) or no (value ). Obviously, it is not easy to understand this philosophical idea, because it is more complex.
The self-contained logic is: The function is also an object, the value is also an object, and the non-value is also a value.
This is all about JavaScript systems. If you want to use it easily, remember the following:
-Three simple value types: string, number, and boolean are used for display on the webpage;
-Objects are used to store other objects, funtion, or the preceding simple value types, and are found using an attribute name using the '.' operation;
-Undefined is used to check whether the data is valid or invalid;
-Function is used for execution.
Of course, if you want to become a thinker or linguistic madman, think about the philosophical proposition above and I will not block you.
3. What I can use my nose to figure out is the amount of data.
Many people may not understand the Direct Volume declaration in JavaScript, but it is indeed very simple. Since most of our advanced languages are
Constant declaration is supported, and even the original assembly language supports immediate values. For example:
// In C
# Define ABYTE 256
// In delphi
Const
ABYTE = 256
; In asm
Mov ah, 256

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.