当前位置:网站首页>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
边栏推荐
- Introducing Software Testing
- How to solve the "safe startup function prevents the operating system from starting" prompt when installing windows10 on parallel desktop?
- X Opencv feature point detection and matching
- Recursion and recursion
- "Learning notes" recursive & recursive
- Design of logic level conversion in high speed circuit
- Live app source code, jump to links outside the station or jump to pages inside the platform
- Correlation analysis summary
- Maxwell equation and Euler formula - link
- Solve the problem that the kaggle account registration does not display the verification code
猜你喜欢

Hcip day 16 notes

2022.02.14

2022 t elevator repair registration examination and the latest analysis of T elevator repair

How will the complete NFT platform work in 2022? How about its core functions and online time?

Common mode interference of EMC

Idea integrates Microsoft TFs plug-in

How to make icons easily

Interpretation of corolla sub low configuration, three cylinder power configuration, CVT fuel saving and smooth, safety configuration is in place

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

Current detection circuit - including op amp current scheme
随机推荐
Current detection circuit - including op amp current scheme
What is the Valentine's Day gift given by the operator to the product?
D25:sequence search (sequence search, translation + problem solving)
Make small tip
Apple released a supplementary update to MacOS Catalina 10.15.5, which mainly fixes security vulnerabilities
Fudan 961 review
Minimum commission for stock account opening. Stock account opening is free. Is online account opening safe
Comment obtenir une commission préférentielle pour l'ouverture d'un compte en bourse? Est - ce que l'ouverture d'un compte en ligne est sécurisée?
Gossip about redis source code 77
D28:maximum sum (maximum sum, translation)
Go error collection | talk about the difference between the value type and pointer type of the method receiver
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
Generic tips
Selenium library 4.5.0 keyword explanation (II)
[MySQL] classification of multi table queries
C # basic knowledge (2)
Gossip about redis source code 79
Hcip day 14 notes
Design of logic level conversion in high speed circuit
Gossip about redis source code 82