Home > Web Front-end > JS Tutorial > body text

Analysis of stack issues in JS

php中世界最好的语言
Release: 2017-11-28 14:32:43
Original
1549 people have browsed it

We all know that Constructor function needs to be called using the new keyword, so the first letter must be capitalized, but the function does not use such a format. Here are a few examples. Stack problem in JS.

It is taboo to add empty values ​​​​in the array

The value has been assigned when it is created, which is the initialization Var a = 10;

JS will Values ​​whose subscripts are not numeric are filtered out and will not be displayed on the interface, but they still exist in fact

// Use subscripts to assign values, otherwise the original data items will be overwritten

//Use subscripts to assign values, if not, create new data items

//Subscripts can use

variables

//Non-numeric subscripts are not counted in the array length , but it can exist.

The current array is equivalent to a

object, which does not have the attribute of index, and returns undefined. If the attribute exists, the attribute of the attribute is returned. Value, this is the most basic. The attribute value may be a function or something else

//Pay attention to the variable type

Unshift()

Shift()

Push()


Pop()

Concat()

Concat() is used to merge arrays without affecting the original array. The form returns

Slice()

slice() is used to split the array without affecting the original array. It returns in the form of a copy

Splice()

The Spilce() operation will directly change the original array

Any JS

built-in function has its own return value. If it does not return, it will return undefined

indexOf()

//This refers to the first position

lastIndexOf()

The above two examples illustrate that the search starting point includes your own position

Reverse()

Sort()

The above is the case where sort() does not pass a value. If a parameter is passed to sort(), it can only be the execution context of a function

The above three forms all achieve the same effect, sorted from small to large


I believe you have mastered the method after reading these cases. For more exciting things, please pay attention to php Other related articles on the Chinese website!


Related reading:

How to make DIV adaptive height

How to use CSS hides the text content of the image background

How to use CSS to hide divs in HTML

The above is the detailed content of Analysis of stack issues in JS. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!