Under normal circumstances we all require the third party JS do not affect their own site loading speed, even if he hangs, also do not affect
document TESTSTTST
Change into
Null and undefined are two types of JavaScript, and the values of the types are as follows:
type
value
Null
Only one value is null
Undefined
Only one value undefined
Null indicates
Let's look at what this difference points to in these situations:
1. This in the global code:
1 alert (This)//windowThis in the global scope will point to the global object, even window in the browser.
The code is as follows
Copy
Order of singular groups
Sort () function
The sort method of an array object can rearrange the array elements in a certain order. Usually, they are arranged in the order of subtitles. When sort () is used, the comparison function is executed each
The original small air (hill) said to me, use object objects less than the array object, because the efficiency of the object is higher, and today just write a JS encountered an array or object with the problem, so simply write the test page.
Usually our writing cycle is roughly like this:
The code is as follows
Copy Code
function () {The way of writing general circulationfor (var i=0; i...}}
Optimization variable Declaration
The above writing in
Example we're going to bind a carriage return event
The code is as follows
Copy Code
$ (function () {Define carriage return Eventsif (Document.addeventlistener) {//if it is FirefoxDocument.addeventlistener ("KeyPress",
Javascript Follow Plugin
Js following scrolling effect plugin
Support for defining multiple follow IDs, using CSS fixed attributes, not supporting IE6, and compatible with other mainstream browsers.
Support defines the minimum height of scrolling
Get URL parameters:
The code is as follows
Copy Code
function Geturlparam (name) {var value = Location.search.match (New RegExp ("[?]" + name + "= ([^&]*) ([O.)", "I"));return value? decodeURIComponent (Value[1]): value;}
Array manipulation functions
Join (delimiter) to use delimiters (delimiter) for each element in the array as a stringConcat (Array1, array2, ...) Merges the array, does not affect the original array, but returns the merged new arrayPop () deletes
Web effects four dynamic display of time date code in Web pagesDisplaying the date time in a Web page is more commonly used, and I've collected four display methods that I hope will help a lot.
Take the parts and make a string connection
code
Use when you link to
Location.replace (URL) ">JavaScript Mask main Window scroll bar
Add it to the body tag.Style= "Overflow-y:hidden"JavaScript screen screen, constantly emptying clipboardAdd it to the body tag.Onload= "SetInterval ('
Split syntax
The decomposition method divides the specified string into strings based on the regular expression or condition. method returns an array of each section found in the string. RegExp See the reference entry.
String.Split (separator,
Conditional statementWhen you write code, you often need to perform different behaviors according to different conditions. You can use conditional statements in your code to accomplish this task.
In JavaScript, we can use the following conditional
A long time ago wrote a universal validation function, we do not laugh ah, many things are not perfect, such as date validation.
Name:
Password:
Theme:
expression: >
content:
Tip: you can modify some code before running Leisure and EntertainmentFood & BeverageConvenient lifeTravelShopping WorldEducation and TrainingDecorationAutomotive WorldOther categoriesMerchants enter more merchantsBeijing Hua Xu digital
Html5 is widely used. To improve user experience, some html5 is often added to webpages. When users browse our websites, js checks whether the browser can support html5, then, give the user a prompt and guidance.Method 1:If (typeof (Worker )! =
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