This article, which I accidentally saw today, shares the same feelings and has always felt that JavaScript is more or less biased. This article tells my mind.
Figure 1. Poor JavaScript (from Practical JavaScript DOM Scripting and Ajax Projects)
Effect demonstration
Lowercase amount:
Capital Amount:
Program code
Function convertCurrency (currencyDigits) {// Constants: var MAXIMUM_NUMBER = 99999999999.99; // Predefine the radix characters and currency symbols for output: var CN_ZERO =
Javascript itself does not support object-oriented features. It does not have an access control operator and does not define the class keyword. It does not support inherited extend or colons, nor does it support virtual functions, however,
When using JSON, some special characters make us unable to wait for the expected results. The following filtering method uses the filtering method in Discuz to help us solve this problem. First, the js code that handles this problem is attached with
In javascript, an object is actually a hash table, such as the following user object:
function user(n, a){ this.name = n; this.age = a; this.toString = function() { return "Name:" + this.name + ", Age:" + this.age; }}var u = new
Before the rise of ajax, many people write JavaScript, which can be said to have no rules at all. Basically, they write anything when they think of it. It is a function one by one, and copy is required for repeated operations, if you accidentally
Sometimes it may be too long to display a text segment, affecting the Display Effect of our page. If it is only English, we can use the String. substring (start, end) function. However, we usually encounter both English and Chinese characters. The
If you use WebQQ, you may find that every time you receive the information, you will see the user or group prompted by the title. Then, the title of the webpage will start to float and be user-friendly, very interesting. This effect is actually not
In many cases, the json text transmitted from the server is complicated. The following functions can convert arrays, strings, and objects into JSON-format content.
JSON = { encode : function(input) { if (!input) return 'null' switch
In Web development, JavaScript and algorithms are also important. The following describes the implementation of some common algorithms in JavaScript, this includes binary classification, String Length determination, array deduplication, insertion
I am often exhausted by its strange syntax when reading many excellent JavaScript source code, so it is necessary to reinforce the basic knowledge of JavaScript from time to time, every time you think about this kind of knowledge or think about it
The following JavaScript color filter allows you to easily design the color for Web pages. You can also see how the common color filter is implemented on the Internet. Only the core JavaScript code is provided here. For other parts such as CSS,
Prototype literal translation is a prototype and the main means for javascript to implement inheritance. Roughly speaking, prototype is a reserved property of functions in javascript, and its value is an object (we can call this object "prototype
In JavaScript 1.6, several useful methods are added to the javascript array: indexOf, lastIndexOf, every, filter, forEach, map, and some. The first two methods can be classified as element locating methods, the subsequent several can be classified
Before learning the scope of JavaScript variables, we should clarify the following points:
The scope of JavaScript variables is based on its unique scope chain.
JavaScript has no block-level scope.
The variables declared in the function are
Sometimes we need to know how many days, hours, or even minutes between two dates. Here we use JavaScript to implement a function to calculate the time difference between two dates. Let's take a look at the Code:
The method is simple, for example,
In Web development, there is often a problem. I have embedded iframe on a page and want to get the value of an element on this iframe page. How can we achieve this?
Let's take a look at the demo:Effect demonstration
Value of the text box in iframe1:
Javascript has a silent blocking feature, that is, when a Browser executes Javascript code, it cannot do anything else at the same time, whether its code is embedded or external.
When the browser encounters a
In order to improve the above
First, we will use a classic example to briefly describe the Inheritance Mechanism in ECMAScript.
There are only two types of geometric shapes, namely, the elliptical shape (circular shape) and the Polygon Shape (having a certain number of edges ).
Let's take a look at the demo:
Simplified
Ming
Now
Generation
Magic
Method
The transparency of the above elements increases gradually when the mouse moves up, while the transparency decreases gradually when the mouse moves out.
Key
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