You can take reference from any other language's array function and try to recreate it in javascript.