Is there a workaround for lightning web component view?

Is there a workaround for lightning web component view?

We found a workaround but I was wondering if there is a more elegant solution to this. Please take a look at the code snippets:

How to clear an array in JavaScript file?

You can add this to your JavaScript file to allow your arrays to be “cleared”: Array.prototype.clear = function () { this.splice (0, this.length); }; Then you can use it like this: var list = [1, 2, 3]; list.clear ();

How to empty an array in JavaScript, Stack Overflow?

This way, the can under “A” is not only empty, but also as clean as new! Furthermore, you are not required to remove the trash by hand until the can is empty! You were asked to empty the existing one, completely, in one turn, not to pick up the trash until the can gets empty, as in:

How to empty an array in ECMAScript 5?

It also works when using “strict mode” in ECMAScript 5 because the length property of an array is a read/write property. Using .splice () will work perfectly, but since the .splice () function will return an array with all the removed items, it will actually return a copy of the original array.

When to call push array.push won’t update?

On a trackable array, when I call push in a wiredMethod, Array.push won’t update the view. We found a workaround but I was wondering if there is a more elegant solution to this.

Why does array.push ( ) not change the pointer?

My guess is that the @track isn’t noticing the original push () in the array since an array is actually only a pointer. When items are added to an array, it will never change the pointer, thus @track sees no change.

How is lightning button considered as child component?

In this case lightning:button is considered as child component. onclick event of this button adds another object to the list of object iterated by parent component A. It’s not needed to refresh the component to see the augmented list. Thanks for contributing an answer to Stack Overflow!