JS Array method RollupShift: Deletes the first item of the original array and returns the value of the deleted element, or returns undefined if the array is emptyvar a = [1,2,3,4,5];var B = A.shift (); a:[2,3,4,5] B:1Unshift: Adds a parameter to the
How to use:
1. Storing cookies
2, Parameter Description: 1, parameter 1:cookie store name, parameter 2:cookie the value to store
3. Examples are as follows:
Setcookie (' method ', match);
1. Get cookies
2, Parameter Description: 1, parameter
I. OverviewJavaScript function hijacking, which is the JavaScript hijacking technology mentioned by foreigners. First of all, and the sword to discuss the problem with the students by chance to see a piece of code, probably wrote:Window.alert =
The example in this article summarizes the JavaScript object creation pattern. Share to everyone for your reference, specific as follows:
It's easy to create objects in JavaScript, you can use object literals or constructors. The common patterns
First, the general algorithm
The first method is more conventional, the test has a bug, the amount of data returned randomly several times after the object directly is a function rather than object. Of course, simple data types should not have this
Generation of random verification codes
1: The main part
var code;
The global definition Validation code function createcode () {code = "";
var codelength = 6;//The length of the authentication code var checkcode =
The example of this article tells the JavaScript implementation of the image scrolling effect. Share to everyone for your reference, specific as follows:
HTML code:
picture scrolling " " Li>"
Scrollpic.js
Some knowledge at that time really did not understand words, can put aside, stay in later to see perhaps can understand.
A few months ago, holding the "JavaScript Advanced Program Design (third edition)", after chewing the creation of objects,
I. Scope of functions
1. Function scopes
Is that the scope is in a "function" where all variables belonging to this function can be used and reused throughout the function.
function foo (a) {
var b = 2;
function Bar () {
//...
}
var c = 3;
A monomer is an object that is used to partition namespaces and organize related properties and methods, and if she can be instantiated, she can only be instantiated once (she can only marry once and not married).
Monomer mode is one of the most
function Test () {
This.name= ' Test ';
var name=2;
This.show=function () {
alert (name);
alert (this.name);//Display Name
}
}
var test=new test ();//Create an object from the constructor
Test.show ()//Output 2 and ' Test ', stating that the object
In the process of the exercises to try the snake game with JS to achieve. Had succeeded.
Idea: Use the 10px*10px div layer as "pixel" and then use the 40*40 matrix 160 "Pixels" to make up the game's interface.
Here's the code:
Copy Code code
Loops are a very common control structure, most things depend on it to do it, in JavaScript we can use for (;;), while (), for (in) three loops, in fact, in these three loops for (in) is very inefficient because he needs to query the hash key, As
The test code included in the book is as follows
Copy Code code as follows:
Example
Note: the latest versions of Firefox seem to have fixed the string concatenation Pro Blem. If you are using Firefox 1.0 or later, the string
Here is the sample code
First effect:
Jsondateformat (jsondate) {//json date format converted to normal format
try {
var date = new Date (parseint ( Jsondate.replace ("/date", ""). Replace (")/", "");
var month = Date.getmonth () + 1
JavaScript in the closure is really a cliché of the problem, the recent interview has been asked, my own ability to express and can not fully support, really crazy. On the way back, I suddenly thought of a very simple thing, in fact, we are doing
Before object.is, we compare values using the two equal sign "= =" or the three equal sign "= =", the three equals is more rigorous, as long as the comparison of the two types of different immediately return false.
In addition, there is and only
Tip
First of all, I know this article is very boring, nothing more than the this in JS, and there have been thousands of articles have written this part of the content;However, I still want to write a about JS in this article, is a summary summed
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