Previously in the group has discussed with the hope of a innerhtml and appendchild who faster things, then did a test, the result is, in IE, innerhtml than appendchild faster, Firefox and Chrome,safari, AppendChild is faster than innerHTML.
The
JS string concatenation has two kinds: with "+" connection, with the join of the array connection.
The code is as follows
Copy Code
var a1=10;var a2=20;a3 = A1 + a2/Digital plus numberAlert (typeof (A3))//numberAlert ("a1
Array
MethodConcat ()The elements are linked into the array.
Every ()Tests whether the assertion function is true for each array element.
Filter ()Returns an array element that satisfies the assertion function.
ForEach
(Refer to the user example)One JS does not change the original array method:
concat: Concatenate multiple arrays, returning a new array
Join: Place all elements in an array with a parameter as a delimiter into one character
Slice:
Change the original array:
Shift: Delete the first element and return the deleted element, empty is undefined
Unshift: Adds an element to the beginning of the array and returns the new length
Pop: Delete the last one and return the
The use of Jsonobject and JsonarrayFirst, the jar package simple IntroductionTo enable the program to execute must introduce the Json-lib package, the Json-lib package is dependent on the following jar package at the same
Array API
Api:application programming Interface, application programming interface;
JS in the object provided by the method is called the API;
instanceof检测一个对象是否是数组;(用来对付复杂数据类型;)// 简单数据类型 typeof ;A instanceof B // A是不是B造出来的;例:
Use:: To refer to constants (including classes and modules) and constructors (such as Array () or nokogiri::html ()).Never use:: To invoke a method.
# bad
someclass::some_method
some_object::some_method
# good
Here are some examples of how the following array functions are used:
Array function
Returns a Variantthat contains an array.
Array (arglist)
The arglist parameter is a comma-delimited list of values assigned to the array elements contained in
JS array use method and example tutorialDefining arraysAn array object is used to store a series of values in a separate variable name.
We use the keyword new to create an array object. The following code defines an array object named MyArray:
The
As shown below:
function (Msgarr) {
var len = msgarr.length;
var n = 0;
var htmlspan = "";
for (var j = 0; J · ';
}
Htmlspan + = ' · ';
var imgs = [];
var img = [];
Img[0] = ' ';
for (var i = 0; i
The above code from a
This standard is based on JavaScript (Netscape) and JScript (Microsoft). Brendan Eich, of Netscape (Navigator 2.0), invented the language, which has appeared in all Netscape and Microsoft browsers since 1996. The development of ECMA-262 began in 1996
Creating and manipulating arrays
1 of the three methods created by the array:
The Var arr=new array ();//creates an empty array without specifying a length.
var arr=new arry (4);//Create an array with a length of 4
var arr=new arry (1,2,3, "a", "B");
It's really five quick tips:
use submit events only on elements
If you want to bind an event handler in a form, you should only bind the submit event on the element, rather than the Submit button for the Click event.
March: That's a good way to
Let's look at some of the array methods implemented by CHROME/15
---------------------------------------------------------------------------------------------
Concat: This said, the only thing to note is that concat is not in-place modification,
JS there is no standard multi-line string representation method, but in the template, in order to ensure the readability of the template, we will inevitably use multi-line strings, so there are a variety of way, here with a jade template as an
The script in 1.HTML must be located between the tags.
Scripts can be placed in the and sections of HTML pages
2. If you need to access an HTML element from JavaScript, you can use the document.getElementById (ID) method
3. You can write
JS optimization for IE6.0 function, summed up a few:
One, string concatenation: Using array stitching
Copy Code code as follows:
function Func2 () {
var start = new Date (). GetTime ();
var array = [];
for (var i = 0; i Array[i]
The javascript| string is often used to assemble a large string to output in the course of scripting development, according to a rule. For example, when writing a script control to control the appearance of the entire control of the HTML tag output,
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.