当前位置:网站首页>Yyds dry goods inventory three JS source code interpretation - getobjectbyproperty method
Yyds dry goods inventory three JS source code interpretation - getobjectbyproperty method
2022-07-03 23:46:00 【Xin Ran】
1. Source screenshot

- getObjectByProperty Method uses recursion
- getObjectById Methods and getObjectByProperty Methods are based on getObjectByProperty Method , So the core method of obtaining objects is getObjectByProperty
2. Code testing
Minor modifications : Put... In the source code this Change to pass more than one parameter , Convenient test , Because local is not object-oriented , The source code is object-oriented
// This method uses recursion
function
getObjectByProperty(
obj,
name,
value) {
if (
obj[
name]
===
value) {
// If there is a match , Will come here
return
obj;
}
for (
let
i
=
0,
l
=
obj.
children.
length;
i
<
l;
i
++) {
const
child
=
obj.
children[
i];
const
object
=
getObjectByProperty(
child,
name,
value);
if (
object
!==
undefined) {
return
object;
}
}
return
undefined;
}
- 1.
- 2.
- 3.
- 4.
- 5.
- 6.
- 7.
- 8.
- 9.
- 10.
- 11.
- 12.
- 13.
- 14.
- 15.
- 16.
3. test
const
res
=
getObjectByProperty(
scene,
'name',
'mySphere')
- 1.
4. Core code description

5. summary
- The use of recursion
- Learn to read the source code , Learn others' coding ideas
边栏推荐
- Hcip 13th day notes
- Report on prospects and future investment recommendations of China's assisted reproductive industry, 2022-2028 Edition
- Selenium library 4.5.0 keyword explanation (III)
- Gossip about redis source code 83
- Esp-idf turns off serial port log output.
- [note] glide process and source code analysis
- X Opencv feature point detection and matching
- Unsafe and CAS principle
- Enter MySQL in docker container by command under Linux
- [untitled]
猜你喜欢

It is forbidden to splice SQL in code

2022 a special equipment related management (elevator) examination questions and a special equipment related management (elevator) examination contents
![[network security] what is emergency response? What indicators should you pay attention to in emergency response?](/img/ff/c733ffbb922760910ab09af3ae2886.jpg)
[network security] what is emergency response? What indicators should you pay attention to in emergency response?

Ningde times and BYD have refuted rumors one after another. Why does someone always want to harm domestic brands?

Hcip day 15 notes

JDBC Technology

Introducing Software Testing

A preliminary study on the middleware of script Downloader

2022 examination of safety production management personnel of hazardous chemical production units and examination skills of safety production management personnel of hazardous chemical production unit

Actual combat | use composite material 3 in application
随机推荐
Ningde times and BYD have refuted rumors one after another. Why does someone always want to harm domestic brands?
Report on the construction and development mode and investment mode of sponge cities in China 2022-2028
2022 system integration project management engineer examination knowledge points: software development model
Selenium library 4.5.0 keyword explanation (I)
Is the controller a single instance or multiple instances? How to ensure the safety of concurrency
Deep learning ----- using NN, CNN, RNN neural network to realize MNIST data set processing
Selenium library 4.5.0 keyword explanation (III)
Pyqt5 sensitive word detection tool production, operator's Gospel
D23:multiple of 3 or 5 (multiple of 3 or 5, translation + solution)
Arc135 partial solution
Idea a method for starting multiple instances of a service
How to prevent malicious crawling of information by one-to-one live broadcast source server
2022 examination of safety production management personnel of hazardous chemical production units and examination skills of safety production management personnel of hazardous chemical production unit
Cgb2201 preparatory class evening self-study and lecture content
Gossip about redis source code 81
Analysis on the scale of China's smart health industry and prediction report on the investment trend of the 14th five year plan 2022-2028 Edition
Make small tip
Docking Alipay process [pay in person, QR code Payment]
Esp-idf turns off serial port log output.
Qtoolbutton - menu and popup mode