Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to understand the histochemistry in javascript

2025-04-08 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article introduces the relevant knowledge of "how to understand the histochemistry in javascript". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

General methods of numerical histochemistry

1. The first and most common method, [] .slice.call method

Function toArray (obj) {

1.

Return [] .slice.call (obj)

two。

/ / Array.prototype.slice.call ()

3.

}

Ps: this method is actually a reference method, the comment part is fully written, and what is returned is an array object.

two。 The second method draws lessons from the makeArray method in jq.

Function makeArray (obj) {

1.

Var target = []

two。

If (obj! = null) {

3.

Var I = obj.length

4.

If (I = null | | typeof obj = = 'string' | | typeof obj = =' function' | |

5. Obj.setInterval) {/ /

If it is a string, a function win object, pay this element to the first element that creates the array and return it

Target [0] = obj

1.

} else {/ / if not the above elements, assign each obj to every index of target through a loop

two。

While (I) {

3.

Target [--I] = obj [I]

4.

}

5.

}

6.

}

7.

Return target

}

3. The third method

Function $arr (ele) {

1.

If (! ele) {

two。

Return []

3.

}

4.

If (ele.toArray) {

5.

Return ele.toArray ()

6.

}

7.

Var length = ele.length | | 0, results = new Array (length)

8.

While (length--) {

9.

Results [length] = ele [length]

10.

}

11.

Return results

twelve。

}

This is the end of the content of "how to understand the histochemistry in javascript". Thank you for your reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report