Here's how we use this property to add three methods to a String object: Trim,ltrim,rtrim (acting like a function with the same name in VBScript)
Copy Code code as follows:
String.prototype.Trim = function ()
{
Return This.replace
Conditional declarations in JavaScript are used to complete behavior under different conditions.
Conditional declaration
When you write code, you often need to perform different behaviors according to different conditions. You can use conditional
This article convention: in the case of a special declaration, an attribute is referred to as a property or method.
Creating objects, object inheritance is actually one thing: the instance object we need obtains the private property through the
event model and its principleBackbone.events is the core of the event implementation, which allows the object to have event capabilities
var Events = Backbone.events = {...}
Object listens to other objects through Listento, triggering
JavaScript Number ObjectJavaScript has only one numeric type.You can use or write numbers without using a decimal point.JavaScript NumbersJavaScript numbers can be used or you can write without using a decimal point:Instance
var pi=3.14;
Learn JavaScript regular Good Article one: http://www.cainiao8.com/web/js_note/js_regular_expression.html
Test : Tests whether a string contains a matching result, contains return true, and does not contain return false.
var str =
The role of event distribution
The easiest thing to do when adding a variety of interactivity to a page is to bind the event to the page element, and then in the event handler, do what we want to do. It's like this code:
Element.onclick =
The difference between a deep copy of an object and a shallow copy is as follows:
Shallow copy: Simply copy the object's reference, not the object itself;Deep copy: Copies all the objects referenced by the copied object.
I. Implementation of a
What is modular development?
In the front-end development, as long as in the script tag embedded in dozens of hundreds of lines of code can achieve some basic interactive effect, later JS received attention, the application is also widely up,
Domobj.onkeydown = function (e) {
if (e) {
e ...
} else{
event ...
}
The above example: if the Firefox browser executes the statement within if, that is, use the E parameter to refer to the "event object".
If the IE browser executes the
Interface: A set of principles for accomplishing a task, function, purpose, etc.
Interfaces in programs: There are several ways to specify what the method name is. (Because the program to complete the task, is through the function or the method to
The inverse cosine of the radian returned by this method. The ACOs method returns the numeric value of 0 and pi for radians between x-1 and 1. Returns Nan if the value of the number is outside this range.Grammar
Math.acos (x);
The
1.typeof operator. For function, String, number, Undefined, and so on, for several types of objects, he is perfectly capable, but for array
Copy Code code as follows:
var arr=new Array ("1", "2", "3", "4", "5");
Alert (typeof (arr)
There are a number of ways to define classes in JS:
1. Factory mode
function car () {
var ocar = new Object;
Ocar.color = "Blue";
Ocar.doors = 4;
Ocar.showcolor = function () {
document.write (This.color)
};
return ocar;
}
var car1 = car ();
var
JavaScript provides full control to handle loops and switch statements. There may be a situation when you need to exit a loop but not reach its bottom. There may also be a situation when you want to skip over a portion of the code block and start
Ternary operator Usage Example:
The ternary operator, as the first name indicates, requires three operands.
Grammar is a condition? Result 1: Results 2;. Here you write the terms on the question mark (?) followed by a colon (:) separated by a
Introduced
Some of the patterns we describe in this article are called initialization mode and performance mode, mainly used in initialization and performance improvement, some of the patterns mentioned before, here is just a summary.
Functions to
javascript: operator
In fact, the operator if you have a computer language base should know, perhaps even more proficient than I am, so I do not explain more, to say a few other unfamiliar bar!
1. In operator: The in operator requires that the
Scope of a variable
To understand closures, you must first understand JavaScript's special variable scope.
The scope of a variable is nothing more than two kinds: global and local variables.
The special point of the JavaScript language is that the
JavaScript allows you to create and open windows that represent HTML text, form objects, and frame. The Window object is the topmost object in the JavaScript client hierarchy, and the form element and all JavaScript code exist in the document, and
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.