9. Comments in Javascript)
Q: How can I use JavaScript
Code ?
A: javascript supports three different types of Annotations:
Comments of the multi-line C style. The content included in/* and */is annotated, for example:
/* This is a comment */
/*
I looked at other materials, including CPU extraction and Mac off-the-shelf.
Code But there is no hard disk serial number. After searching for a long time, we can find the parameter for extracting the hard disk serial number. So I made it up.
This document describes the current window or the specified window object. It contains the content of the document from to .
Usage: Document (current window) or . Document (specified window)
Attribute:
Document. Title // set the document title is
In the subconscious, JavaScript will not be written using object-oriented ideas.
Code And seldom learn more about prototype, closures, and other concepts. This leads to poor code writing.
The most important thing to learn about Javascript is to
GlobalObject
Global objects are the most special objects in ecmascript, because they do not exist at all. If you try to write the followingCode, An error is returned:
The error message shows that global is not an object, but didn't Global be
To this end, I have collected some JavaScript Functions that I usually use. They are also common in other JS libraries. Now I want to sort them out and add comments for your convenience. I hope they will help you.
Note: assume that all of the
It would be better to create regular expressions literally. Obviously, sometimes we have to use the large-consumption creation method new Regexp (). For example, regular expressions are used in syntax highlighting and formatting, the more Patten you
Today we will mainly discuss how to encapsulate data in JavaScript scripts ).
Data encapsulation simply hides content that the caller does not want to see. It is object-oriented
Program The first three elements of the design are inheritance and
Two custom JS functions that implement mutual conversion between strings and arrays hope to be useful to you:
CopyCode The Code is as follows: function stringtoarray (STR, substr ){
/* Function: Splits a string into an Array Based on the specified
Let's take a look at the two paragraphs.
Code They use the for loop and regular expression to detect the length of the string in bytes:
For loop detection string Byte Length Method 1:
Copy code The Code is as follows: var lenfor = function
String connection
1. Most Commonly Used + =
I always said that the efficiency of this method is the lowest. Why? Let's take a look at the substantive process of this method.
VaR STR = "hello ";
STR + = "world ";
(1) create a string that stores
1) describes the eval function usage in javascript.
(2) how to execute global code in the function
►First, let's talk about eval usage. The content is relatively simple and you can skip it if you are familiar with it.The eval function receives a
Online demo
I usually like to use it to write some practical tools or applications. This article demonstrates how to use JavaScript to guess the number of games in the "open-mouth" of "the invincible Referer, in the future, I will upload my own
I vaguely remembered the ins and outs and cheered for my own experience.
I vaguely remember the feeling of helplessness and determination after I was tortured by this same problem for countless times.
First of all, I must thank those who have
1. Compile js Functions
2. Add the id attribute to the html element to be displayed/hidden
control the display/hide of this tr
3. Add buttons and links to trigger js functions.
display/hide
Javascript hide layer advertisement
2. Two
Convert to Boolean type
All values in JavaScript can be implicitly converted to the Boolean type, for example:
Copy codeThe Code is as follows: 0 = false; // true 1 = true; // true ''= false // true null = false // true
However, these values are not
The result is as follows: When you click a question, the following reply content is displayed.
Copy codeThe Code is as follows: script type = "text/javascript">
Onload = function (){
Faq (document. getElementsByTagName ("dl") [0], "dt", "dd ");
/*
*
Javascript is no exception, but have you considered object reference? The common practice is a series of object sharing class methods, instead of copying a function for each object. The following describes how to copy a function for each
1. check whether there is an Item with Value = "paraValue" in the select option.
2. add an Item to the select option
3. delete an Item from the select option
4. Delete the selected items in the select statement.
5. In the select option, set the text
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