Best method to search a children id? very fast ?[SOLVED]

Hi
What would be the most effective way, for find a child or (sprite) in the _pictureContainer ?
PHP:
SceneManager._scene._spriteset._pictureContainer.children
The problem is that I have a lot of picture and their CHILD id are messy.!

I use the filter() method, but it is very heavy in resource, especially that can not BREAK; after the first result. !

PHP:
var pictureChild = SceneManager._scene._spriteset._pictureContainer.children.filter(function(pic) { return pic._pictureId === id; });
pictureChild.children.removeChildren(); // remove all children inside this sprite picture
Would there be? a method to quickly get the child's position ? or a way to stored Childposition in the Game Screen constructor with is INDEX ???

I would have liked, use the find () method, but it seem only ECMAScript 6 🙁
What are your tips and advice?

and do existe something in a class , to do example
.getChildAt() ?

thank a lot for help
Just loop through the children with a normal for loop and break once you have what you need.
Code:
var child;
for (var i = 0; i < children.length; i++) {
  if (children[i].someId === IDIWANT) {
    child = children[i];
    break;
  }
}

And as for the es6 functions, you can find polyfills for most of them. You can find them in external libraries or just at the mdn site. example the polyfill for Array.find can be found at the bottom of:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/find
Just loop through the children with a normal for loop and break once you have what you need.
Code:
var child;
for (var i = 0; i < children.length; i++) {
  if (children[i].someId === IDIWANT) {
    child = children[i];
    break;
  }
}

And as for the es6 functions, you can find polyfills for most of them. You can find them in external libraries or just at the mdn site. example the polyfill for Array.find can be found at the bottom of:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/find
Thank you, I did not know this term !.
i was use https://www.w3schools.com/js/ to learn & study javascript.
and not have the Polyfill !

So if I understood correctly to stay clean, I can do a js file
with all Polyfill i need
example Polyfill.js
and add im to index.html , before load my plugin.js

PHP:
<body style="background-color: black">
        <script type="text/javascript" src="js/libs/pixi.js"></script>
        <script type="text/javascript" src="js/libs/pixi-tilemap.js"></script>
        <script type="text/javascript" src="js/libs/pixi-picture.js"></script>
        <script type="text/javascript" src="js/libs/fpsmeter.js"></script>
        <script type="text/javascript" src="js/libs/lz-string.js"></script>
        <script type="text/javascript" src="js/libs/iphone-inline-video.browser.js"></script>
        <script type="text/javascript" src="js/rpg_core.js"></script>
        <script type="text/javascript" src="js/rpg_managers.js"></script>
        <script type="text/javascript" src="js/rpg_objects.js"></script>
        <script type="text/javascript" src="js/rpg_scenes.js"></script>
        <script type="text/javascript" src="js/rpg_sprites.js"></script>
        <script type="text/javascript" src="js/rpg_windows.js"></script>
<script type="text/javascript" src="js/Polyfill.js"></script>
        <script type="text/javascript" src="js/plugins.js"></script>
        <script type="text/javascript" src="js/main.js"></script>
    </body>
Just a thought but if you know the id and since all ids for the children should be unique could you perhaps use Array.prototype.indexOf?
Code:
var child;
var id = children.indexOf(IDIWANT);
child = children[id];
Just a thought but if you know the id and since all ids for the children should be unique could you perhaps use Array.prototype.indexOf?
Code:
var child;
var id = children.indexOf(IDIWANT);
child = children[id];
In fact when we are tired we makes us stupid and incompetent.
All the pictures are well in order !!
I confused the pictureID with the spriteID !, we must admit that if we read quickly. We can confused :dizzy:
aeafdf.jpg
So calling a filter is completely stupid.
so i simply do this now and is work !

PHP:
    var pictureChild = SceneManager._scene._spriteset._pictureContainer.children[pictureId-1];
    if(pictureChild.children.length){pictureChild.removeChildren()}; // removePixiText child
I know the feeling lol. There are normally a ton of ways to do something and 99% of them are overly complicated (figures out an easier way which in turn allows you to find an even simpler way). 😛

Original thread: https://forums.rpgmakerweb.com/threads/best-method-to-search-a-children-id-very-fast-solved.80521/