DEV Community

loading...

Discussion on: Essential Vanilla JavaScript Functions

Collapse
lexlohr profile image
Alex Lohr

Interesting approach for array_unique (even taking into account that objects and arrays in the array might have different pointers, but have the same content. There's just one minor issue: x in y will also return true for the constructor attribute, so better use y.hasOwnProperty(x). If your array contains 'constructor' as a string, your function will filter it out.

Collapse
amit_merchant profile image
Amit Merchant Author

Yeah. We can implement it that way as well. If you want you can send over a pull request on github.com/amitmerchant1990/essent...

Collapse
lexlohr profile image
Alex Lohr

There you go.