当前位置:网站首页>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
边栏推荐
- [note] IPC traditional interprocess communication and binder interprocess communication principle
- Hcip day 12 notes
- Idea a method for starting multiple instances of a service
- D24:divisor and multiple (divisor and multiple, translation + solution)
- 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?
- 炒股开户佣金优惠怎么才能获得,网上开户安全吗
- "Learning notes" recursive & recursive
- MLX90614 driver, function introduction and PEC verification
- Scratch uses runner Py run or debug crawler
- IO flow principle and classification
猜你喜欢
MLX90614 driver, function introduction and PEC verification
Ningde times and BYD have refuted rumors one after another. Why does someone always want to harm domestic brands?
2022 Guangdong Provincial Safety Officer a certificate third batch (main person in charge) simulated examination and Guangdong Provincial Safety Officer a certificate third batch (main person in charg
Current detection circuit - including op amp current scheme
2022 chemical automation control instrument examination content and chemical automation control instrument simulation examination
"Learning notes" recursive & recursive
EPF: a fuzzy testing framework for network protocols based on evolution, protocol awareness and coverage guidance
Smart fan system based on stm32f407
Deep learning ----- using NN, CNN, RNN neural network to realize MNIST data set processing
The first game of the new year, many bug awards submitted
随机推荐
Bufferpool caching mechanism for executing SQL in MySQL
Hcip day 16 notes
How will the complete NFT platform work in 2022? How about its core functions and online time?
2022.02.13
Hcip day 12 notes
Ramble 72 of redis source code
Alibaba cloud container service differentiation SLO hybrid technology practice
2022 t elevator repair registration examination and the latest analysis of T elevator repair
Gossip about redis source code 78
Idea set class header comments
Selenium library 4.5.0 keyword explanation (4)
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?
Arc135 partial solution
Interpretation of corolla sub low configuration, three cylinder power configuration, CVT fuel saving and smooth, safety configuration is in place
Amway by head has this project management tool to improve productivity in a straight line
[15th issue] Tencent PCG background development internship I, II and III (OC)
Gossip about redis source code 74
A preliminary study on the middleware of script Downloader
2022 free examination questions for hoisting machinery command and hoisting machinery command theory examination
The interviewer's biggest lie to deceive you, bypassing three years of less struggle