Copy Code code as follows:
Remove the header space of the string (left space)
function LTrim (str) {
var i;
for (i=0;iif (Str.charat (i)!= "") break;
}
str = str.substring (i,str.length);
return str;
}
Remove the trailing
Copy Code code as follows:
function Test () {
this.name = ' Test ';
return function () {return true;}
}
var test = new Test (); What's the test here?
Is it a Test object? Wrong! Here test is the function () {return true;} that
For the question of whether the JavaScript function parameter is a byVal or a pass (BYREF), there is a common misconception that "simple types" such as number,string are values, number, String, Object, array, and so on "complex types." is the
Any programming uses code reuse, otherwise every time you develop a new program or write a new feature, you need to write new words, that's a good break, but the code reuse is also bad, the next two articles we will discuss the code reuse, the first
Recently did the Web page schedule printing, the Internet to find some information, and finally use the following method to achieve the functions I need. Place the table in the DIV tag where you want to print the schedule, and then specify the area
Code
Copy Code code as follows:
function String.prototype.Trim () {return this.replace (/^/s*) | ( /s*$)/g, ""); Remove left and right spaces
function String.prototype.Ltrim () {return this.replace (/(^/s*)/g, "");} Remove left
Copy Code code as follows:
/*
* Function: To determine whether the user entered the correct mailbox format
* Reference: None
* Return value: TRUE or False
*/
function Form_check () {
var email = document.getElementById ("email"). Value;
There are 10 check boxes, the maximum number of users can only tick 3, otherwise, all the check boxes will be grayed out.
(The user can still select again when the check box is checked out again.) )
Set the variable part to the parameters of JS to
Set Cookies
Each cookie is a name/value pair, and you can assign a string such as the following to Document.cookie:
Document.cookie= "userid=828";
If you want to store more than one name/value pair at a time, you can use a semicolon plus a space (
The effect of Eval is simply to pass a string to the JS interpreter, which the JavaScript interpreter interprets as JavaScript code and executes it.For the simplest example:
Copy Code code as follows:
Eval ("Alert (1+1)");
Script>
If you use a function or method call to explicitly convert a type to another type, called a display transformation, it is called an implicit type conversion. Google and Wikipedia did not find the word "show type conversion", "Implicit type
Part I: Key events in the browser
Use JS to implement keyboard records, to pay attention to the browser's three key event types, that is, keydown,keypress and KeyUp, they correspond to the onkeydown, onkeypress and onkeyup These three event handles
Real-life problems may be abstracted into such a data model:
Select a few numbers from an array and let the numbers add up to the specified value.
Most readers should have the experience of online shopping, online shopping will generally have a
Forget all the object-oriented knowledge you learned before. Just consider the car situation here. Yes, it's the car.
Recently I was watching Hours of Le Mans, a popular tournament in France. The fastest car is called the Le Mans prototype car.
One, what is Console.log ()?In addition to some very old versions of browsers, most browsers now have their own debugging capabilities, and can be supplemented by installing plug-ins even without debugging. For example, the old version of Firefox
JavaScript anonymous function, which means that a function does not have a name, let's list the test code
Copy Code code as follows:
/*
* Commonly common functions are like this
*/
function Debug (data) {
Console.log (data);
This example demonstrates the way JavaScript determines the type of file upload, which is a very common technique. The implementation methods are as follows:
File upload with a function, using the HTML element input tag implementation:
This article illustrates some of the techniques commonly used by JavaScript beginners. Share for everyone to use for reference. Specifically as follows:
One, javascript program storage location
inside of HTML inside of HTML*.js file inside
To understand it according to the location of this, the situation can be divided into 3 kinds:
1, in the function: this is usually an implied parameter.
2, outside the function (in the top-level scope): In the browser this refers to the global
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.