Substr definition and usage
The substr () method extracts a specified number of characters starting with the start subscript from a string.
SyntaxStringobject. substr (START, length)
Parameters
Description
Start
Function expression
1. A function defined in JavaScript can be used for two minutes:
1-1. function declaration:
Copy codeThe Code is as follows: function funcName (arg1, arg2, arg3 ){
// Function body
}
① Name attribute: the name of the function
Instance 1 -- controls the constant movement and stop of an object
HTML:
Copy codeThe Code is as follows:
JS: Implement right motionCopy codeCode: var timer = null;Window. onload = function (){Var odiv = document. getElementById ('d1 ');Var obtn
1. Allow only numbers to be entered in the text box, and use the text box control of asp.net mvc3.0
Copy codeThe Code is as follows: @ Html. TextBox ("txt", null, new {@ style = "width: 300;", onkeypress = "return RegValidateIsDigit (event )"})
You
Create a class for the constructor method as follows:
Copy codeThe Code is as follows: function className (prop_1, prop_2, prop_3 ){
This. prop1 = prop_1;
This. prop2 = prop_2;
This. prop3 = prop_3 ;}
With the above class, we can create an instance
For Loop:
Copy codeThe Code is as follows: for (I = start; I
}
While loop: (Note: if the condition is always true, it will enter an endless loop, and the browser will drop the hang)Copy codeThe Code is as follows: while (condition ){// Do something;
Constructor and prototype inheritance Defects
First, we will analyze the defects of the constructor and prototype chain inheritance methods:
The main problem with Constructors (Object impersonating) is that they must use the constructor method and
Copy codeThe Code is as follows:
Copy codeThe Code is as follows: using System;
Using System. Collections. Generic;
Using System. ComponentModel;
Using System. Data;
Using System. Drawing;
Using System. Linq;
Using System. Text;
Using
Yesterday, I encountered a problem when writing the last dynamically generated year, month, day drop-down box and text box restriction input. when entering the text box, I began to calculate the number of words entered in the text box, naturally, I
Javascript does not support real classes like Java, C #, and other languages. However, pseudo classes can be defined in js. The tool to achieve this is the constructor and prototype object. First, we will introduce the constructors in js.
The
Sample Code:
Copy codeThe Code is as follows: var date1 = new Date (maid, 1 );
Var date2 = new Date (maid, 1 );
Date1 = date2; // The execution result is false.
Date1 === date2; // The execution result is false.
Var num1 = new Number (10 );Var num2
Copy codeThe Code is as follows: var intervalBody = function (){
Console. log ('interval ');
}
Var startInterval = function (){SetInterval (FIG, 1000 );}
Var timeoutBody = function (){Console. log ('timeout ');}
Var startTimeout = function
Many people know this pointer. The main purpose of this article is to train new people in our company.The default this Pointer PointsRule 1By default, this pointer points to the object specified for a method call, such as obj. fun (). this Pointer
Generally, an object in javascript is a pointer to prototype and a list of its own properties. Javascript adopts the concept of copy-on-write when creating objects.Only the constructor has the prototype attribute. prototype inheritance creates a new
The rules for writing XHTML code are much stricter than those for compiling HTML code. Similar code below is valid in HTML, but it is invalid in XHTML.
[Javascript]
Copy codeThe Code is as follows:
In HTML, there are special rules used to
PrefaceIn JavaScript, scopes, contexts, closures, and functions are the essence. For Junior JSer, it is an advanced necessity. For front-end captors, they can write elegant code only by keeping calm and understanding the essence.
This article aims
1
,
Window. onerror
Event
The onerror event is used to help handle JavaScript errors on the page. When an exception occurs on the page, the error event is triggered on the window object. For example:
In this case, the browser displays the error
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