当前位置:网站首页>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
边栏推荐
- 2.14 summary
- C # basic knowledge (1)
- [Happy Valentine's day] "I still like you very much, like sin ² a+cos ² A consistent "(white code in the attached table)
- Pyqt5 sensitive word detection tool production, operator's Gospel
- Docking Alipay process [pay in person, QR code Payment]
- I would like to ask how the top ten securities firms open accounts? Is it safe to open an account online?
- Smart fan system based on stm32f407
- What is the Valentine's Day gift given by the operator to the product?
- Briefly understand the operation mode of developing NFT platform
- [15th issue] Tencent PCG background development internship I, II and III (OC)
猜你喜欢
How to make recv have a little temper?
Hcip day 12 notes
Yyds dry goods inventory [practical] simply encapsulate JS cycle with FP idea~
Pyqt5 sensitive word detection tool production, operator's Gospel
2022.02.14
Apple released a supplementary update to MacOS Catalina 10.15.5, which mainly fixes security vulnerabilities
Kubedl hostnetwork: accelerating the efficiency of distributed training communication
Gorilla/mux framework (RK boot): add tracing Middleware
Tencent interview: can you pour water?
Research Report on the scale prediction of China's municipal engineering industry and the prospect of the 14th five year plan 2022-2028
随机推荐
Ningde times and BYD have refuted rumors one after another. Why does someone always want to harm domestic brands?
Ningde times and BYD have refuted rumors one after another. Why does someone always want to harm domestic brands?
C # basic knowledge (3)
[network security] what is emergency response? What indicators should you pay attention to in emergency response?
Arc135 partial solution
What is the Valentine's Day gift given by the operator to the product?
Selenium library 4.5.0 keyword explanation (I)
D24:divisor and multiple (divisor and multiple, translation + solution)
[source code] VB6 chat robot
EPF: a fuzzy testing framework for network protocols based on evolution, protocol awareness and coverage guidance
股票開戶傭金最低的券商有哪些大家推薦一下,手機上開戶安全嗎
Exclusive download! Alibaba cloud native brings 10 + technical experts to bring "new possibilities of cloud native and cloud future"
炒股开户佣金优惠怎么才能获得,网上开户安全吗
Alibaba cloud container service differentiation SLO hybrid technology practice
Ningde times and BYD have refuted rumors one after another. Why does someone always want to harm domestic brands?
QT creator source code learning note 05, how does the menu bar realize plug-in?
Hcip 13th day notes
2022.02.13
Amway by head has this project management tool to improve productivity in a straight line
[MySQL] sql99 syntax to realize multi table query