1.0.15 β€’ Published 7 months ago

jsmimic-php v1.0.15

Weekly downloads
-
License
MIT
Repository
-
Last release
7 months ago

What is jsmimic-php? πŸ€”

jsmimic-php is a JS library that allows you to mimic PHP functions in JavaScript. This library is useful for people who are familiar with PHP and want to use JavaScript but don't have the time to learn the JavaScript equivalents of PHP functions.

Installation πŸ› οΈ

To install jsmimic-php:

using npm

npm install jsmimic-php

using yarn

yarn add jsmimic-php

Usage πŸ“–

Note: Multi-dimensional arrays in php are represented as objects in JavaScript.

Example:

array(1, 2, array(3, 4)) // in php

is the same thing as πŸ‘‡πŸ½

[1, 2, {0: 3, 1: 4}] // in JS.

and

array('name' => 'John Doe', 'age' => 20) // in php

is the same thing as πŸ‘‡πŸ½

{name: 'John Doe', age: 20} // in JS.

This is because JavaScript arrays can only have numeric keys, while PHP arrays can have both numeric and string keys.

In more simple terms, JavaScript arrays can only have one dimension, while PHP arrays can have multiple dimensions, by multiple dimensions, I mean arrays within arrays or nested arrays.

but JavaScript arrays can only have arrays within objects, not arrays within arrays.

Not clear enough? πŸ€”

if you want to use multi-dimensional arrays in JavaScript, you can use objects instead and if you want to use objects in JavaScript, you can also use maps instead.

Example:

array('name' => 'John Doe', 'age' => 20) // in php 

is the same thing as πŸ‘‡πŸ½

new Map([['name', 'John Doe'], ['age', 20]]) // in JS.
// or
{name: 'John Doe', age: 20} // in JS.

pheew! πŸ˜…, that was a lot to take in, but I hope you understand now. 😊 So let's officially get started. πŸš€

To use jsmimic-php, you must first import it into your project:

const jsmp = require('jsmimic-php');

// or

import jsmp from 'jsmimic-php';

or you can import the functions from the library individually:

const { array_chunk, array_combine, array_change_key_case } = require('jsmimic-php');

// or

import { array_chunk, array_combine, array_change_key_case } from 'jsmimic-php';

Then, you can use the functions in jsmimic-php: just like in PHP, but this time in JavaScript. 😎

// Example 1: Using the `array_combine` function

const keys = ['name', 'age'];
const values = ['John Doe', 20];

const arr = array_combine(keys, values); // { name: 'John Doe', age: 20 }




// Example 2: Using the `array_change_key_case` function

const arr = {
    name: 'John Doe',
    age: 20
};

const newArr = array_change_key_case(arr, 'CASE_UPPER'); // { NAME: 'John Doe', AGE: 20 }


// Example 3: Using the `array_chunk` function

const arr = [1, 2, 3, 4, 5];

const newArr = array_chunk(arr, 2); // [[1, 2], [3, 4], [5]]

Documentation πŸ“š

Available Array functions:

IndexFunctionDescriptionExample
1array_change_key_caseChanges all keys in an array to lowercase or uppercase.Example
2array_chunkSplit an array into chunks.Example
3array_columnReturn the values from a single column in the input array.Example
4array_combineCreates an array by using one array for keys and another for its values.Example
5array_count_valuesCounts all the values of an array.Example
6array_diff_assocComputes the difference of arrays with additional index check.Example
7array_diff_keyComputes the difference of arrays using keys for comparison.Example
8array_diff_uassocComputes the difference of arrays with additional index check which is performed by a user supplied callback function.Example
9array_diff_ukeyComputes the difference of arrays using a callback function on the keys for comparison.Example
10array_diffComputes the difference of arrays.Example
11array_fill_keysFill an array with values, specifying keys.Example
12array_fillFill an array with values.Example
13array_filterFilters elements of an array using a callback function.Example
14array_flipExchanges all keys with their associated values in an array.Example
15array_intersect_assocComputes the intersection of arrays with additional index check.Example
16array_intersect_keyComputes the intersection of arrays using keys for comparison.Example
17array_intersect_uassocComputes the intersection of arrays with additional index check, compares indexes by a callback function.Example
18array_intersect_ukeyComputes the intersection of arrays using a callback function on the keys for comparison.Example
19array_intersectComputes the intersection of arrays.Example
20array_is_listChecks if the given array is a list.Example
21array_key_existsChecks if the given key or index exists in the array.Example
22array_key_firstGets the first key of an array.Example
23array_key_lastGets the last key of an array.Example
24array_keysReturn all the keys or a subset of the keys of an array.Example
25array_mapApplies the callback to the elements of the given arrays.Example
26array_merge_recursiveMerge two or more arrays recursively.Example
27array_mergeMerge one or more arrays.Example
28array_multisortSort multiple or multi-dimensional arrays.Example
29array_padPad array to the specified length with a value.Example
30array_productCalculate the product of values in an array.Example
31array_pushPush one or more elements onto the end of array.Example
32array_randPick one or more random keys out of an array.Example
33array_reduceIteratively reduce the array to a single value using a callback function.Example
34array_replaceReplaces elements from passed arrays into the first array.Example
35array_reverseReturn an array with elements in reverse order.Example
36array_searchSearches the array for a given value and returns the first corresponding key if successful.Example
37array_shiftShift an element off the beginning of array.Example
38array_sliceExtract a slice of the array.Example
39array_spliceRemove a portion of the array and replace it with something else.Example
40array_sumCalculate the sum of values in an array.Example
41array_udiff_assocComputes the difference of arrays with additional index check, compares data by a callback function.Example
42array_udiff_uassocComputes the difference of arrays with additional index check, compares data and indexes by a callback function.Example
43array_udiffComputes the difference of arrays by using a callback function for data comparison.Example
44array_uintersect_assocComputes the intersection of arrays with additional index check, compares data by a callback function.Example
45array_uintersect_uassocComputes the intersection of arrays with additional index check, compares data and indexes by separate callback functions.Example
46array_uintersectComputes the intersection of arrays, compares data by a callback function.Example
47array_uniqueRemoves duplicate values from an array.Example
48array_unshiftPrepend one or more elements to the beginning of an array.Example
49array_valuesReturn all the values of an array.Example
50array_walk_recursiveApply a user function recursively to every member of an array.Example
51array_walkApply a user supplied function to every member of an array.Example
52arrayCreate an array.Example
53arsortSort an array in reverse order and maintain index association.Example
54asortSort an array and maintain index association.Example
55compactCreate array containing variables and their values.Example
56countCount all elements in an array, or something in an object.Example
57currentReturn the current element in an array.Example
58eachReturn the current key and value pair from an array and advance the array cursor.Example
59endSet the internal pointer of an array to its last element.Example
60in_arrayChecks if a value exists in an array.Example
61key_existsAlias of array_key_exists.Example
62keyFetch a key from an array.Example
63krsortSort an array by key in reverse order.Example
64ksortSort an array by key.Example
65listAssign variables as if they were an array.Example
66natcasesortSort an array using a case insensitive "natural order" algorithm.Example
67natsortSort an array using a "natural order" algorithm.Example
68nextAdvance the internal array pointer of an array.Example
69rangeCreate an array containing a range of elements.Example
70resetSet the internal pointer of an array to its first element.Example
71rsortSort an array in reverse order.Example
72shuffleShuffle an array.Example
73sizeofAlias of count.Example
74sortSort an array.Example
75uasortSort an array with a user-defined comparison function and maintain index association.Example
76uksortSort an array by keys using a user-defined comparison function.Example
77usortSort an array by values using a user-defined comparison function.Example

Roadmap πŸ—ΊοΈ

  • Add more functions from the PHP array functions
  • Add more functions from other PHP functions for other data types like strings, integers, etc.
  • Add more tests. πŸ§ͺ
  • Add more documentation. πŸ“š
  • Add more examples. πŸ“

Examples πŸ“

1. array_change_key_case

Description:

The array_change_key_case function is used to change the case of all keys in an array to either uppercase or lowercase.

Parameters:
  • array (Object): The input array whose keys you want to transform.
  • case (String): The case transformation option. Use 'CASE_UPPER' to change keys to uppercase or 'CASE_LOWER' to change keys to lowercase.
Usage Example:
const originalArray = {
    name: 'John Doe',
    age: 20
};

// Change keys to uppercase
const newArrayUpperCase = array_change_key_case(originalArray, 'CASE_UPPER'); // { NAME: 'John Doe', AGE: 20 }

// Change keys to lowercase
const newArrayLowerCase = array_change_key_case(originalArray, 'CASE_LOWER'); // { name: 'John Doe', age: 20 }
Explanation:

The array_change_key_case function takes two parameters: the input array and the desired case transformation ('CASE_UPPER' for uppercase, 'CASE_LOWER' for lowercase). It transforms the keys of the array to the specified case while preserving the original values. The resulting array is an object where each key is a key from the original array and each value is a value from the original array. The array_change_key_case function is useful when you want to change the case of all keys in an array to either uppercase or lowercase.

2. array_chunk

Description:

The array_chunk function is used to split an array into smaller chunks, each containing a specified number of elements.

Parameters:
  • array (Array): The input array to be chunked.
  • size (Number): The size of each chunk.
  • preserveKeys (Boolean): (Optional) If set to true, the function will preserve the original keys. Default is false.

Usage Example:

const originalArray = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];

const newArr = array_chunk(originalArray, 3); // [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10]]


// works with strings too
const textArray = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j'];

const newTextArr = array_chunk(textArray, 4); // [['a', 'b', 'c', 'd'], ['e', 'f', 'g', 'h'], ['i', 'j']]
Explanation:

The array_chunk function takes two parameters: the input array and the size of each chunk. It divides the original array into smaller arrays, each containing the specified number of elements (except the last chunk, which may have fewer elements if there are not enough remaining). The resulting array is a multidimensional array where each element is a chunk of the original array. The array_chunk function is useful when you want to split an array into smaller chunks.

3. array_column

This function returns the values from a single column in the input array.

Parameters
  • array (Array): The input array.
  • columnKey (String): The column of values to return.
const arr = [
    { id: 1, name: 'John Doe', age: 20 },
    { id: 2, name: 'Jane Doe', age: 25 },
    { id: 3, name: 'Mary Doe', age: 30 },
    { id: 4, name: 'Mark Doe', age: 35 },
    { id: 5, name: 'Mike Doe', age: 40 },
];

const newArr = array_column(arr, 'name'); // ['John Doe', 'Jane Doe', 'Mary Doe', 'Mark Doe', 'Mike Doe']
Explanation

The array_column function takes two parameters: the input array and the column of values to return. It returns the values from a single column in the input array. The resulting array is an array of values from the specified column. The array_column function is useful when you want to return the values from a single column in the input array.

4. array_combine

This function creates an array by using one array for keys and another for its values.

Parameters:
  • keys (Array): Array of keys to be used. Illegal values for key will be converted to string.
  • values (Array): Array of values to be used.
  • preserveKeys (Boolean): (Optional) If set to true, the function will preserve the original keys. Default is false.
const keys = ['name', 'age'];

const values = ['John Doe', 20];

const arr = array_combine(keys, values); // { name: 'John Doe', age: 20 }
Explanation:

The array_combine function takes two parameters: the array of keys and the array of values. It creates an array by using the first array for keys and the second array for values. The resulting array is an object where each key is a key from the first array and each value is a value from the second array. The array_combine function is useful when you want to create an associative array from two arrays.

5. array_count_values

This function counts all the values of an array.

Parameters:
  • array (Array): The array of values to count.
const arr = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5];

const newArr = array_count_values(arr); // { '1': 2, '2': 2, '3': 2, '4': 2, '5': 2 }
Explanation:

The array_count_values function takes one parameter: the array of values to count. It counts all the values of the array and returns an object where each key is a value from the array and each value is the number of times that value appears in the array. The array_count_values function is useful when you want to count the number of occurrences of each value in an array.

6. array_diff_assoc

This function computes the difference of arrays in array1 but not in array2 with additional index check.

Parameters:
  • array1 (Array): The array to compare from.
  • array2 (Array): An array to compare against.
const arr1 = [1, 2, 3, 4, 5, 8, 10, 11, 12];

const arr2 = [1, 2, 3, 4, 5, 6];

const newArr = array_diff_assoc(arr1, arr2); // [8, 10, 11, 12]
Explanation:

The array_diff_assoc function takes two parameters: the array to compare from and the array to compare against. It computes the difference of arrays in array1 but not in array2 with additional index check. The resulting array is an array of values from array1 that are not in array2. The array_diff_assoc function is useful when you want to find the difference between two arrays with additional index check.

7. array_diff_key

This function computes the difference of arrays that is in array1 but not in array2 using keys for comparison.

Parameters:
  • array1 (Array): The array to compare from.
  • array2 (Array): An array to compare against.
const array1 = { key1: 'value1', key2: 'value2', key3: 'value3' };

const array2 = { key2: 'value2', key4: 'value4', key5: 'value5' };

const newArr = array_diff_key(array1, array2); // { key1: 'value1', key3: 'value3' }
Explanation:

The array_diff_key function takes two parameters: the array to compare from and the array to compare against. It computes the difference of arrays that is in array1 but not in array2 using keys for comparison. The resulting array is an object of values from array1 that are not in array2. The array_diff_key function is useful when you want to find the difference between two arrays using keys for comparison.

8. array_diff_uassoc

This function computes the difference of arrays with additional index check which is performed by a user supplied callback function.

Parameters:
  • array1 (Array): The array to compare from.
  • array2 (Array): An array to compare against.
  • callback (Function): The callback function to use for comparison.
const arr1 = [1, 2, 3, 4, 5, 8, 10, 11, 12];

const arr2 = [1, 2, 3, 4, 5, 6];

const newArr = array_diff_uassoc(arr1, arr2, (a, b) => a - b); // [8, 10, 11, 12] sorted in ascending order
Explanation:

The array_diff_uassoc function takes three parameters: the array to compare from, the array to compare against and the callback function to use for comparison. It computes the difference of arrays with additional index check which is performed by a user supplied callback function. The resulting array is an array of values from array1 that are not in array2. The array_diff_uassoc function is useful when you want to find the difference between two arrays with additional index check which is performed by a user supplied callback function.

9. array_diff_ukey

This function computes the difference of arrays that is in array1 but not in array2 using a callback function on the keys for comparison.

Parameters:
  • array1 (Array): The array to compare from.
  • array2 (Array): An array to compare against.
  • callback (Function): The callback function to use for comparison.
const dataset1 = { 'a': 'apple', 'b': 'banana', 'c': 'cherry' };

const dataset2 = { 'b': 'banana', 'd': 'date', 'e': 'elderberry' };

function customKeyCompare(a, b) {
  return a.toLowerCase() === b.toLowerCase() ? 0 : -1;
}

const differentKeys = array_diff_ukey(dataset1, dataset2, customKeyCompare); // { 'a': 'apple', 'c': 'cherry' }
Explanation:

The array_diff_ukey function takes three parameters: the array to compare from, the array to compare against and the callback function to use for comparison. It computes the difference of arrays that is in array1 but not in array2 using a callback function on the keys for comparison. The resulting array is an object of values from array1 that are not in array2. The array_diff_ukey function is useful when you want to find the difference between two arrays using a callback function on the keys for comparison.

10. array_diff

This function computes the difference of arrays.

Parameters:
  • array1 (Array): The array to compare from.
  • array2 (Array): An array to compare against.
const arr1 = [1, 2, 3, 4, 5];

const arr2 = [4, 5, 6, 7, 8];

const newArr = array_diff(arr1, arr2); // [1, 2, 3]
Explanation:

The array_diff function takes two parameters: the array to compare from and the array to compare against. It computes the difference of arrays. The resulting array is an array of values from array1 that are not in array2. The array_diff function is useful when you want to find the difference between two arrays.

11. array_fill_keys

This function fills an array with values, specifying keys.

Parameters:
  • keys (Array): Array of values that will be used as keys.
  • value (Any): Value to use for filling.
const arr = array_fill_keys(['foo', 5, 10, 'bar'], 'banana'); // { foo: 'banana', '5': 'banana', '10': 'banana', bar: 'banana' }
Explanation:

The array_fill_keys function takes two parameters: the array of keys and the value to use for filling. It fills an array with values, specifying keys. The resulting array is an object where each key is a key from the first array and each value is the value to use for filling. The array_fill_keys function is useful when you want to fill an array with values, specifying keys.

12. array_fill

This function fills an array with values.

Parameters:
  • startIndex (Number): The first index of the returned array.
  • num (Number): Number of elements to insert.
  • value (Any): Value to use for filling.
const arr = array_fill(5, 6, 'banana'); // [ 'banana', 'banana', 'banana', 'banana', 'banana', 'banana' ]

const filledArray = array_fill(0, 5, 'default'); // [ 'default', 'default', 'default', 'default', 'default' ]
Explanation:

The array_fill function takes three parameters: the first index of the returned array, the number of elements to insert and the value to use for filling. It fills an array with values. The resulting array is an array of values from array1 that are not in array2. The array_fill function is useful when you want to fill an array with values.

13. array_filter

This function filters elements of an array using a callback function.

Parameters:
  • array (Array): The array to iterate over.
  • callback (Function): The callback function to use for filtering. If no callback is supplied, all entries of array equal to false will be removed.
const arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];

const newArr = array_filter(arr, (value) => value % 2 === 0); // [2, 4, 6, 8, 10]
Use Case:

The array_filter function takes two parameters: the array to iterate over and the callback function to use for filtering. It filters elements of an array using a callback function. The resulting array is an array of values from array1 that are not in array2. The array_filter function is useful when you want to filter elements of an array using a callback function.

14. array_flip

This function exchanges all keys with their associated values in an array.

Parameters:
  • array (Array): The array of key/value pairs to be flipped.
const arr = { name: 'John Doe', age: 20 };

const newArr = array_flip(arr); // { 'John Doe': 'name', '20': 'age' }
Explanation:

The array_flip function takes one parameter: the array of key/value pairs to be flipped. It exchanges all keys with their associated values in an array. The resulting array is an object where each key is a value from the first array and each value is a key from the first array. The array_flip function is useful when you want to exchange all keys with their associated values in an array.

15. array_intersect_assoc

This function computes the intersection of arrays with additional index check.

Parameters:
  • array1 (Array): The array to compare from.
  • array2 (Array): An array to compare against.
const arr1 = [1, 2, 3, 4, 5, 8, 10, 11, 12];

const arr2 = [1, 2, 3, 4, 5, 6];

const newArr = array_intersect_assoc(arr1, arr2); // [1, 2, 3, 4, 5]
Explanation:

The array_intersect_assoc function takes two parameters: the array to compare from and the array to compare against. It computes the intersection of arrays with additional index check. The resulting array is an array of values from array1 that are also in array2. The array_intersect_assoc function is useful when you want to find the intersection between two arrays with additional index check.

16. array_intersect_key

This function computes the intersection of arrays using keys for comparison.

Parameters:
  • array1 (Array): The array to compare from.
  • array2 (Array): An array to compare against.
const array1 = { key1: 'value1', key2: 'value2', key3: 'value3' };

const array2 = { key2: 'value2', key4: 'value4', key5: 'value5' };

const newArr = array_intersect_key(array1, array2); // { key2: 'value2' }
Explanation:

The array_intersect_key function takes two parameters: the array to compare from and the array to compare against. It computes the intersection of arrays using keys for comparison. The resulting array is an object of values from array1 that are also in array2. The array_intersect_key function is useful when you want to find the intersection between two arrays using keys for comparison.

17. array_intersect_uassoc

This function computes the intersection of arrays with additional index check, compares indexes by a callback function.

Parameters:
  • array1 (Array): The array to compare from.
  • array2 (Array): An array to compare against.
  • callback (Function): The callback function to use for comparison.
const arr1 = [1, 2, 3, 4, 5, 8, 10, 11, 12];

const arr2 = [1, 2, 3, 4, 5, 6];

const newArr = array_intersect_uassoc(arr1, arr2, (a, b) => a - b); // [1, 2, 3, 4, 5] sorted in ascending order
Explanation:

The array_intersect_uassoc function takes three parameters: the array to compare from, the array to compare against and the callback function to use for comparison. It computes the intersection of arrays with additional index check, compares indexes by a callback function. The resulting array is an array of values from array1 that are also in array2. The array_intersect_uassoc function is useful when you want to find the intersection between two arrays with additional index check, compares indexes by a callback function.

18. array_intersect_ukey

This function computes the intersection of arrays using a callback function on the keys for comparison.

Parameters:
  • array1 (Array): The array to compare from.
  • array2 (Array): An array to compare against.
  • callback (Function): The callback function to use for comparison.
const dataset1 = { 'a': 'apple', 'b': 'banana', 'c': 'cherry' };

const dataset2 = { 'b': 'banana', 'd': 'date', 'e': 'elderberry' };

function customKeyCompare(a, b) {
  return a.toLowerCase() === b.toLowerCase() ? 0 : -1;
}

const differentKeys = array_intersect_ukey(dataset1, dataset2, customKeyCompare); // { 'b': 'banana' }
Explanation:

The array_intersect_ukey function takes three parameters: the array to compare from, the array to compare against and the callback function to use for comparison. It computes the intersection of arrays using a callback function on the keys for comparison. The resulting array is an object of values from array1 that are also in array2. The array_intersect_ukey function is useful when you want to find the intersection between two arrays using a callback function on the keys for comparison.

19. array_intersect

This function computes the intersection of arrays.

Parameters:
  • array1 (Array): The array to compare from.
  • array2 (Array): An array to compare against.
const arr1 = [1, 2, 3, 4, 5];

const arr2 = [4, 5, 6, 7, 8];

const newArr = array_intersect(arr1, arr2); // [4, 5]
Explanation:

The array_intersect function takes two parameters: the array to compare from and the array to compare against. It computes the intersection of arrays. The resulting array is an array of values from array1 that are also in array2. The array_intersect function is useful when you want to find the intersection between two arrays.

20. array_is_list

This function checks if the given array is a list and returns true if the array is a list and false otherwise.

Parameters:
  • array (Array): The array to check.
const arr = [1, 2, 3, 4, 5];

const isList = array_is_list(arr); // true
Explanation:

The array_is_list function takes one parameter: the array to check. It checks if the given array is a list and returns true if the array is a list and false otherwise. The array_is_list function is useful when you want to check if the given array is a list.

21. array_key_exists

This function checks if the given key or index exists in the array.

Parameters:
  • key (String): Value to check.
  • array (Array): An array with keys to check.
const arr = { name: 'John Doe', age: 20 };

const keyExists = array_key_exists('name', arr); // true
Explanation:

The array_key_exists function takes two parameters: the key to check and the array with keys to check. It checks if the given key or index exists in the array and returns true if the key exists and false otherwise. The array_key_exists function is useful when you want to check if the given key or index exists in the array.

22. array_key_first

This function gets the first key of an array.

Parameters:
  • array (Array): The array to get the first key from.
const arr = { name: 'John Doe', age: 20 };

const firstKey = array_key_first(arr); // 'name'
Explanation:

The array_key_first function takes one parameter: the array to get the first key from. It gets the first key of an array and returns the key. The array_key_first function is useful when you want to get the first key of an array.

23. array_key_last

This function gets the last key of an array.

Parameters:
  • array (Array): The array to get the last key from.
const arr = { name: 'John Doe', age: 20 };

const lastKey = array_key_last(arr); // 'age'
Explanation:

The array_key_last function takes one parameter: the array to get the last key from. It gets the last key of an array and returns the key. The array_key_last function is useful when you want to get the last key of an array.

24. array_keys

This function returns all the keys or a subset of the keys of an array.

Parameters:
  • array (Array): The array to get the keys from.
const arr = { name: 'John Doe', age: 20 };

const keys = array_keys(arr); // ['name', 'age']
Explanation:

The array_keys function takes one parameter: the array to get the keys from. It returns all the keys or a subset of the keys of an array. The array_keys function is useful when you want to get all the keys or a subset of the keys of an array.

25. array_map

This function applies a callback function to each element of an array and returns the resulting array.

Parameters:
  • callback (Function): The callback function to use for mapping.
  • array (Array): The array to iterate over.
const arr = [1, 2, 3, 4, 5];

const newArr = array_map((value) => value * 2, arr); // [2, 4, 6, 8, 10]
Explanation:

The array_map function takes two parameters: the callback function to use for mapping and the array to iterate over. It applies a callback function to each element of an array and returns the resulting array. The array_map function is useful when you want to apply a callback function to each element of an array and return the resulting array.

26. array_merge_recursive

This function merges two or more arrays recursively.

Parameters:
  • array1 (Array): The first array to merge.
  • array2 (Array): The second array to merge.
  • ...arrays (Array): (Optional) The arrays to merge.
const arr1 = { name: 'John Doe', age: 20 };

const arr2 = { name: 'Jane Doe', age: 21 };

const mergedArr = array_merge_recursive(arr1, arr2); // { name: ['John Doe', 'Jane Doe'], age: [20, 21] }
Explanation:

The array_merge_recursive function takes two or more parameters: the arrays to merge. It merges two or more arrays recursively. The resulting array is an object where each key is a key from the first array and each value is an array of values from the merged arrays. The array_merge_recursive function is useful when you want to merge two or more arrays recursively.

27. array_merge

This function merges two or more arrays.

Parameters:
  • array1 (Array): The first array to merge.
  • array2 (Array): The second array to merge.
  • ...arrays (Array): (Optional) The arrays to merge.
const arr1 = { name: 'John Doe', age: 20 };

const arr2 = { name: 'Jane Doe', age: 21 };

const mergedArr = array_merge(arr1, arr2); // { name: 'Jane Doe', age: 21 }
Explanation:

The array_merge function takes two or more parameters: the arrays to merge. It merges two or more arrays. The resulting array is an object where each key is a key from the first array and each value is a value from the merged arrays. The array_merge function is useful when you want to merge two or more arrays.

28. array_multisort

This function sorts multiple or multi-dimensional arrays.

Parameters:
  • array (Array): The array to sort.
  • column (Object): The array of sorting columns descriptors. Each column descriptor has the following format: { column: 5, order: 'ASC' }.
const arr = [
    { name: 'John Doe', age: 20 },
    { name: 'Jane Doe', age: 21 },
    { name: 'James Doe', age: 22 },
    { name: 'Jenny Doe', age: 23 },
];

const sortedArr = array_multisort(arr, [{ column: 'age', order: 'ASC' }]); 
// [{ name: 'John Doe', age: 20 }, { name: 'Jane Doe', age: 21 }, { name: 'James Doe', age: 22 }, { name: 'Jenny Doe', age: 23 }]
Explanation:

The array_multisort function takes two parameters: the array to sort and the array of sorting columns descriptors. It sorts multiple or multi-dimensional arrays. The resulting array is an array of values from the first array sorted by the sorting columns descriptors. The array_multisort function is useful when you want to sort multiple or multi-dimensional arrays.

29. array_pad

This function pads an array to a specified length with a specified value.

Parameters:
  • array (Array): The array to pad.
  • size (Number): The new size of the array.
  • value (Any): Value to use for padding.
const arr = [1, 2, 3, 4, 5];

const newArr = array_pad(arr, 10, 'default'); 
// [1, 2, 3, 4, 5, 'default', 'default', 'default', 'default', 'default']
Explanation:

The array_pad function takes three parameters: the array to pad, the new size of the array and the value to use for padding. It pads an array to a specified length with a specified value. The resulting array is an array of values from the first array padded to the specified length with the specified value. The array_pad function is useful when you want to pad an array to a specified length with a specified value.

30. array_product

This function calculates the product of values in an array.

Parameters:
  • array (Array): The array to calculate the product of values from.
const arr = [1, 2, 3, 4, 5];

const product = array_product(arr); // 120
Explanation:

The array_product function takes one parameter: the array to calculate the product of values from. It calculates the product of values in an array. The resulting array is an array of values from the first array with the last element removed. The array_product function is useful when you want to calculate the product of values in an array.

31. array_push

This function pushes one or more elements onto the end of an array.

Parameters:
  • array (Array): The array to push elements to.
  • ...elements (Any): The elements to push.
const arr = [1, 2, 3, 4, 5];

const newArr = array_push(arr, 6, 7, 8, 9, 10); // [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
Explanation:

The array_push function takes two or more parameters: the array to push elements to and the elements to push. It pushes one or more elements onto the end of an array. The resulting array is an array of values from the first array with the pushed elements. The array_push function is useful when you want to push one or more elements onto the end of an array.

32. array_rand

This function picks one or more random keys out of an array.

Parameters:
  • array (Array): The array to pick random keys from.
  • num (Number): (Optional) Specifies how many random keys to pick. Default is 1.
const arr = [1, 2, 3, 4, 5];

const randomKey = array_rand(arr); // 3
Explanation:

The array_rand function takes one or two parameters: the array to pick random keys from and the number of random keys to pick.

It picks one or more random keys out of an array. The resulting array is an array of random keys from the first array. The array_rand function is useful when you want to pick one or more random keys out of an array.

33. array_reduce

This function reduces an array to a single value by using a callback function.

Parameters:
  • array (Array): The array to reduce.
  • callback (Function): The callback function to use for reducing.
const arr = [1, 2, 3, 4, 5];

const sum = array_reduce(arr, (accumulator, currentValue) => accumulator + currentValue); 
// 15
Explanation:

The array_reduce function takes two parameters: the array to reduce and the callback function to use for reducing. It reduces an array to a single value by using a callback function. The resulting array is an array of values from the first array reduced to a single value by using a callback function. The array_reduce function is useful when you want to reduce an array to a single value by using a callback function.

34. array_replace

This function replaces elements from passed arrays into the first array.

Parameters:
  • array1 (Array): The array to replace elements in.
  • array2 (Array): The array to replace elements from.
const arr1 = { name: 'John Doe', age: 20 };

const arr2 = { name: 'Jane Doe', age: 21 };

const replacedArr = array_replace(arr1, arr2); 
// { name: 'Jane Doe', age: 21 }
Explanation:

The array_replace function takes two parameters: the array to replace elements in and the array to replace elements from. It replaces elements from passed arrays into the first array. The resulting array is an object where each key is a key from the first array and each value is a value from the second array. The array_replace function is useful when you want to replace elements from passed arrays into the first array.

35. array_reverse

This function returns an array with elements in reverse order.

Parameters:
  • array (Array): The array to reverse.
const arr = [1, 2, 3, 4, 5];

const reversedArr = array_reverse(arr);
// [5, 4, 3, 2, 1]
Explanation:

The array_reverse function takes one parameter: the array to reverse. It returns an array with elements in reverse order. The resulting array is an array of values from the first array in reverse order. The array_reverse function is useful when you want to return an array with elements in reverse order.

36. array_search

This function searches an array for a given value and returns the corresponding key if successful.

Parameters:
  • value (Any): The value to search for.
  • array (Array): The array to search in.
const arr = { name: 'John Doe', age: 20 };

const key = array_search('John Doe', arr);
// 'name'
Explanation:

The array_search function takes two parameters: the value to search for and the array to search in. It searches an array for a given value and returns the corresponding key if successful. The resulting array is an array of values from the first array in reverse order. The array_search function is useful when you want to search an array for a given value and return the corresponding key if successful.

37. array_shift

This function shifts the first value of the array off and returns it.

Parameters:
  • array (Array): The array to shift.
const arr = [1, 2, 3, 4, 5];

const shiftedValue = array_shift(arr);
// 1
Explanation:

The array_shift function takes one parameter: the array to shift. It shifts the first value of the array off and returns it. The resulting array is an array of values from the first array with the first value removed. The array_shift function is useful when you want to shift the first value of the array off and return it.

38. array_slice

This function returns a slice of the array.

Parameters:
  • array (Array): The array to slice.
  • offset (Number): The offset to start the slice from.
  • length (Number): (Optional) The length of the slice. If length is omitted, the slice will have everything from offset up until the end of the array.
const arr = [1, 2, 3, 4, 5];

const slicedArr = array_slice(arr, 2, 2);
// [3, 4]
Explanation:

The array_slice function takes two or three parameters: the array to slice, the offset to start the slice from and the length of the slice. It returns a slice of the array. The resulting array is an array of values from the first array sliced from the offset to the length. The array_slice function is useful when you want to return a slice of the array.

39. array_splice

This function removes a portion of the array and replaces it with something else.

Parameters:
  • array (Array): The array to splice.
  • start (Number): The index at which to start changing the array.
  • deleteCount (Number): (Optional) The number of elements in the array to remove from start.
  • elements (Any): (Optional) The elements to add to the array from start.
const arr = [1, 2, 3, 4, 5];

const splicedArr = array_splice(arr, 2, 2, 6, 7, 8, 9, 10);
// [1, 2, 6, 7, 8, 9, 10, 5]
Explanation:

The array_splice function takes three or more parameters: the array to splice, the index at which to start changing the array, the number of elements in the array to remove from start and the elements to add to the array from start. It removes a portion of the array and replaces it with something else. The resulting array is an array of values from the first array with the spliced elements. The array_splice function is useful when you want to remove a portion of the array and replace it with something else.

40. array_sum

This function calculates the sum of values in an array.

Parameters:
  • array (Array): The array to calculate the sum of values from.
const arr = [1, 2, 3, 4, 5];

const sum = array_sum(arr); // 15
Explanation:

The array_sum function takes one parameter: the array to calculate the sum of values from. It calculates the sum of values in an array. The resulting array is an array of values from the first array with the last element removed. The array_sum function is useful when you want to calculate the sum of values in an array.

41. array_udiff_assoc

This function computes the difference of arrays with additional index check, compares data by a callback function.

Parameters:
  • array1 (Array): The array to compare from.
  • array2 (Array): An array to compare against.
  • callback (Function): The callback function to use for comparison.
const arr1 = [1, 2, 3, 4, 5, 8, 10, 11, 12];

const arr2 = [1, 2, 3, 4, 5, 6];

const newArr = array_udiff_assoc(arr1, arr2, (a, b) => a - b); // [8, 10, 11, 12] sorted in ascending order
Explanation:

The array_udiff_assoc function takes three parameters: the array to compare from, the array to compare against and the callback function to use for comparison. It computes the difference of arrays with additional index check, compares data by a callback function. The resulting array is an array of values from array1 that are not in array2. The array_udiff_assoc function is useful when you want to find the difference between two arrays with additional index check, compares data by a callback function.

42. array_udiff_uassoc

This function computes the difference of arrays with additional index check, compares data and indexes by a callback function.

Parameters:
  • array1 (Array): The array to compare from.
  • array2 (Array): An array to compare against.
  • dataCompareCallback (Function): The callback function to use for data comparison.
  • indexCompareCallback (Function): The callback function to use for index comparison.
const arr1 = [1, 2, 3, 4, 5, 8, 10, 11, 12];

const arr2 = [1, 2, 3, 4, 5, 6];

const newArr = array_udiff_uassoc(arr1, arr2, (a, b) => a - b, (a, b) => a - b);
// [8, 10, 11, 12] sorted in ascending order
Explanation:

The array_udiff_uassoc function takes four parameters: the array to compare from, the array to compare against, the callback function to use for data comparison and the callback function to use for index comparison. It computes the difference of arrays with additional index check, compares data and indexes by a callback function. The resulting array is an array of values from array1 that are not in array2. The array_udiff_uassoc function is useful when you want to find the difference between two arrays with additional index check, compares data and indexes by a callback function.

43. array_udiff

This function computes the difference of arrays by using a callback function for data comparison.

Parameters:
  • array1 (Array): The array to compare from.
  • array2 (Array): An array to compare against.
  • callback (Function): The callback function to use for data comparison.
const arr1 = [1, 2, 3, 4, 5, 8, 10, 11, 12];

const arr2 = [1, 2, 3, 4, 5, 6];

const newArr = array_udiff(arr1, arr2, (a, b) => a - b); 
// [8, 10, 11, 12] sorted in ascending order
Explanation:

The array_udiff function takes three parameters: the array to compare from, the array to compare against and the callback function to use for data comparison. It computes the difference of arrays by using a callback function for data comparison. The resulting array is an array of values from array1 that are not in array2. The array_udiff function is useful when you want to find the difference between two arrays by using a callback function for data comparison.

44. array_uintersect_assoc

This function computes the intersection of arrays with additional index check, compares data by a callback function.

Parameters:
  • array1 (Array): The array to compare from.
  • array2 (Array): An array to compare against.
  • callback (Function): The callback function to use for data comparison.
const arr1 = [1, 2, 3, 4, 5, 8, 10, 11, 12];

const arr2 = [1, 2, 3, 4, 5, 6];

const newArr = array_uintersect_assoc(arr1, arr2, (a, b) => a - b);
// [1, 2, 3, 4, 5] sorted in ascending order
Explanation:

The array_uintersect_assoc function takes three parameters: the array to compare from, the array to compare against and the callback function to use for data comparison. It computes the intersection of arrays with additional index check, compares data by a callback function. The resulting array is an array of values from array1 that are also in array2. The array_uintersect_assoc function is useful when you want to find the intersection between two arrays with additional index check, compares data by a callback function.

45. array_uintersect_uassoc

This function computes the intersection of arrays with additional index check, compares data and indexes by a callback function.

Parameters:
  • array1 (Array): The array to compare from.
  • array2 (Array): An array to compare against.
  • dataCompareCallback (Function): The callback function to use for data comparison.
  • indexCompareCallback (Function): The callback function to use for index comparison.
const arr1 = [1, 2, 3, 4, 5, 8, 10, 11, 12];

const arr2 = [1, 2, 3, 4, 5, 6];

const newArr = array_uintersect_uassoc(arr1, arr2, (a, b) => a - b, (a, b) => a - b);
// [1, 2, 3, 4, 5] sorted in ascending order
Explanation:

The array_uintersect_uassoc function takes four parameters: the array to compare from, the array to compare against, the callback function to use for data comparison and the callback function to use for index comparison. It computes the intersection of arrays with additional index check, compares data and indexes by a callback function. The resulting array is an array of values from array1 that are also in array2. The array_uintersect_uassoc function is useful when you want to find the intersection between two arrays with additional index check, compares data and indexes by a callback function.

46. array_uintersect

This function computes the intersection of arrays by using a callback function for data comparison.

Parameters:
  • array1 (Array): The array to compare from.
  • array2 (Array): An array to compare against.
  • callback (Function): The callback function to use for data comparison.
const arr1 = [1, 2, 3, 4, 5, 8, 10, 11, 12];

const arr2 = [1, 2, 3, 4, 5, 6];

const newArr = array_uintersect(arr1, arr2, (a, b) => a - b);
// [1, 2, 3, 4, 5] sorted in ascending order
Explanation:

The array_uintersect function takes three parameters: the array to compare from, the array to compare against and the callback function to use for data comparison. It computes the intersection of arrays by using a callback function for data comparison. The resulting array is an array of values from array1 that are also in array2. The array_uintersect function is useful when you want to find the intersection between two arrays by using a callback function for data comparison.

47. array_unique

This function removes duplicate values from an array.

Parameters:
  • array (Array): The array to remove duplicate values from.
const arr = [1, 2, 3, 4, 5, 5, 4, 3, 2, 1];

const uniqueArr = array_unique(arr);
Explanation:

The array_unique function takes one parameter: the array to remove duplicate values from. It removes duplicate values from an array. The resulting array is an array of values from the first array with duplicate values removed. The array_unique function is useful when you want to remove duplicate values from an array.

48. array_unshift

This function prepends one or more elements to the beginning of an array.

Parameters:
  • array (Array): The array to prepend elements to.
  • ...elements (Any): The elements to prepend.
const arr = [1, 2, 3, 4, 5];

const newArr = array_unshift(arr, 6, 7, 8, 9, 10); 
// [6, 7, 8, 9, 10, 1, 2, 3, 4, 5]
Explanation:

The array_unshift function takes two or more parameters: the array to prepend elements to and the elements to prepend. It prepends one or more elements to the beginning of an array. The resulting array is an array of values from the first array with the prepended elements. The array_unshift function is useful when you want to prepend one or more elements to the beginning of an array.

49. array_values

This function returns all the values of an array.

Parameters:
  • array (Array): The array to get the values from.
const arr = { name: 'John Doe', age: 20 };

const values = array_values(arr); // ['John Doe', 20]
Explanation:

The array_values function takes one parameter: the array to get the values from. It returns all the values of an array. The resulting array is an array of values from the first array. The array_values function is useful when you want to get all the values of an array.

50. array_walk_recursive

This function applies a user function recursively to every member of an array.

Parameters:
  • array (Array): The array to apply the callback function to.
  • callback (Function): The callback function to apply.
const arr = [1, 2, 3, 4, 5];

const newArr = array_walk_recursive(arr, (value, key) => console.log(value, key));
// 1 0
Explanation:

The array_walk_recursive function takes two parameters: the array to apply the callback function to and the callback function to apply. It applies a user function recursively to every member of an array. The resulting array is an array of values from the first array with the callback function applied to each value. The array_walk_recursive function is useful when you want to apply a user function recursively to every member of an array.

51. array_walk

This function applies a user function to every member of an array.

Parameters:
  • array (Array): The array to apply the callback function to.
  • callback (Function): The callback function to apply.
const arr = [1, 2, 3, 4, 5];

const newArr = array_walk(arr, (value, key) => console.log(value, key));
// 1 0
Explanation:

The array_walk function takes two parameters: the array to apply the callback function to and the callback function to apply. It applies a user function to every member of an array. The resulting array is an array of values from the first array with the callback function applied to each value. The array_walk function is useful when you want to apply a user function to every member of an array.

52. array

This function creates an array.

Parameters:
  • ...elements (Any): The elements to add to the array.
const arr = array(1, 2, 3, 4, 5);
// [1, 2, 3, 4, 5]
Explanation:

The array function takes one or more parameters: the elements to add to the array. It creates an array. The resulting array is an array of values from the parameters. The array function is useful when you want to create an array.

53. arsort

This function sorts an array in reverse order and maintains index association.

Parameters:
  • array (Array): The array to sort.
const arr = [1, 2, 3, 4, 5];

const sortedArr = arsort(arr);
// [5, 4, 3, 2, 1]
Explanation:

The arsort function takes one parameter: the array to sort. It sorts an array in reverse order and maintains index association. The resulting array is an array of values from the first array sorted in reverse order. The arsort function is useful when you want to sort an array in reverse order and maintain index association.

54. asort

This function sorts an array and maintains index association.

Parameters:
  • array (Array): The array to sort.
const arr = [1, 2, 3, 4, 5];

const sortedArr = asort(arr);
// [1, 2, 3, 4, 5]
Explanation:

The asort function takes one parameter: the array to sort. It sorts an array and maintains index association. The resulting array is an array of values from the first array sorted. The asort function is useful when you want to sort an array and maintain index association.

55. compact

This function creates an array containing variables and their values.

Parameters:
  • ...variables (Any): The variables to add to the array.
const name = 'John Doe';

const age = 20;

const arr = compact(name, age);
// { name: 'John Doe', age: 20 }
Explanation:

The compact function takes one or more parameters: the variables to add to the array. It creates an array containing variables and their values. The resulting array is an array of values from the parameters. The compact function is useful when you want to create an array containing variables and their values.

56. count

This function counts all elements in an array or something in an object.

Parameters:
  • array (Array): The array to count elements from.
const arr = [1, 2, 3, 4, 5];

const count = count(arr);
// 5
Explanation:

The count function takes one parameter: the array to count elements from. It counts all elements in an array or something in an object. The resulting array is an array of values from the first array with the callback function applied to each value. The count function is useful when you want to count all elements in an array or something in an object.

57. current

This function returns the current element in an array.

Parameters:
  • array (Array): The array to get the current element from.
const arr = [1, 2, 3, 4, 5];

const currentElement = current(arr);
// 1
Explanation:

The current function takes one parameter: the array to get the current element from. It returns the current element in an array. The resulting array is an array of values from the first array with the callback function applied to each value. The current function is useful when you want to return the current element in an array.

58. each

This function returns the current element in an array.

Parameters:
  • array (Array): The array to get the current element from.
const arr = [1, 2, 3, 4, 5];

const currentElement = each(arr);
// 1
Explanation:

The each function takes one parameter: the array to get the current element from. It returns the current element in an array. The resulting array is an array of values from the first array with the callback function applied to each value. The each function is useful when you want to return the current element in an array.

59. end

This function returns the last element in an array.

Parameters:
  • array (Array): The array to get the last element from.
const arr = [1, 2, 3, 4, 5];

const lastElement = end(arr);
// 5
Explanation:

The end function takes one parameter: the array to get the last element from. It returns the last element in an array. The resulting array is an array of values from the first array with the callback function applied to each value. The end function is useful when you want to return the last element in an array.

60. in_array

This function checks if a value exists in an array.

Parameters:
  • value (Any): The value to check for.
  • array (Array): The array to check in.
const arr = [1, 2, 3, 4, 5];

const exists = in_array(3, arr);
// true
Explanation:

The in_array function takes two parameters: the value to check for and the array to check in. It checks if a value exists in an array. The resulting array is an array of values from the first array with the callback function applied to each value. The in_array function is useful when you want to check if a value exists in an array.

61. key_exists

This function checks if a key exists in an array.

Parameters:
  • key (Any): The key to check for.
  • array (Array): The array to check in.
const arr = { name: 'John Doe', age: 20 };

const exists = key_exists('name', arr);
// true
Explanation:

The key_exists function takes two parameters: the key to check for and the array to check in. It checks if a key exists in an array. The resulting array is an array of values from the first array with the callback function applied to each value. The key_exists function is useful when you want to check if a key exists in an array.

62. krsort

This function sorts an array by key in reverse order.

Parameters:
  • array (Array): The array to sort.
const arr = [1, 2, 3, 4, 5];

const sortedArr = krsort(arr);
// [5, 4, 3, 2, 1]
Explanation:

The krsort function takes one parameter: the array to sort. It sorts an array by key in reverse order. The resulting array is an array of values from the first array sorted by key in reverse order. The krsort function is useful when you want to sort an array by key in reverse order.

63. ksort

This function sorts an array by key.

Parameters:
  • array (Array): The array to sort.
const arr = [1, 2, 3, 4, 5];

const sortedArr = ksort(arr);
// [1, 2, 3, 4, 5]
Explanation:

The ksort function takes one parameter: the array to sort. It sorts an array by key. The resulting array is an array of values from the first array sorted by key. The ksort function is useful when you want to sort an array by key.

64. List

This function assigns variables as if they were an array.

Parameters:
  • ...variables (Any): The variables to assign.
const arr = [1, 2, 3, 4, 5];

const [a, b, c, d, e] = List(...arr);
// a = 1, b = 2, c = 3, d = 4, e = 5
Explanation:

The List function takes one or more parameters: the variables to assign. It assigns variables as if they were an array. The resulting array is an array of values from the parameters. The List function is useful when you want to assign variables as if they were an array.

65. natcasesort

This function sorts an array using a case insensitive "natural order" algorithm.

Parameters:
  • array (Array): The array to sort.
const arr = [1, 2, 3, 4, 5];

const sortedArr = natcasesort(arr);
// [1, 2, 3, 4, 5]
Explanation:

The natcasesort function takes one parameter: the array to sort. It sorts an array using a case insensitive "natural order" algorithm. The resulting array is an array of values from the first array sorted using a case insensitive "natural order" algorithm. The natcasesort function is useful when you want to sort an array using a case insensitive "natural order" algorithm.

66. natsort

This function sorts an array using a "natural order" algorithm.

Parameters:
  • array (Array): The array to sort.
const arr = [1, 2, 3, 4, 5];

const sortedArr = natsort(arr);
Explanation:

The natsort function takes one parameter: the array to sort. It sorts an array using a "natural order" algorithm. The resulting array is an array of values from the first array sorted using a "natural order" algorithm. The natsort function is useful when you want to sort an array using a "natural order" algorithm.

67. next

This function advances the internal pointer of an array.

Parameters:
  • array (Array): The array to advance the internal pointer of.
const arr = [1, 2, 3, 4, 5];

const nextElement = next(arr);
Explanation:

The next function takes one parameter: the array to advance the internal pointer of. It advances the internal pointer of an array. The resulting array is an array of values from the first array with the callback function applied to each value. The next function is useful when you want to advance the internal pointer of an array.

68. reset

This function resets the internal pointer of an array.

Parameters:
  • array (Array): The array to reset the internal pointer of.
const arr = [1, 2, 3, 4, 5];

const resetElement = reset(arr);
// 1
Explanation:

The reset function takes one parameter: the array to reset the internal pointer of. It resets the internal pointer of an array. The resulting array is an array of values from the first array with the callback function applied to each value. The reset function is useful when you want to reset the internal pointer of an array.

69. rsort

This function sorts an array in reverse order.

Parameters:
  • array (Array): The array to sort.
const arr = [1, 2, 3, 4, 5];

const sortedArr = rsort(arr);
// [5, 4, 3, 2, 1]
Explanation:

The rsort function takes one parameter: the array to sort. It sorts an array in reverse order. The resulting array is an array of values from the first array sorted in reverse order. The rsort function is useful when you want to sort an array in reverse order.

70. shuffle

This function shuffles an array.

Parameters:
  • array (Array): The array to shuffle.
const arr = [1, 2, 3, 4, 5];

const shuffledArr = shuffle(arr);
// [1, 3, 2, 5, 4]
Explanation:

The shuffle function takes one parameter: the array to shuffle. It shuffles an array. The resulting array is an array of values from the first array shuffled. The shuffle function is useful when you want to shuffle an array.

71. sizeof

This function counts all elements in an array or something in an object.

Parameters:
  • array (Array): The array to count elements from.
const arr = [1, 2, 3, 4, 5];
// 5
Explanation:

The sizeof function takes one parameter: the array to count elements from. It counts all elements in an array or something in an object. The resulting

1.0.15

7 months ago

1.0.14

7 months ago

1.0.13

7 months ago

1.0.11

7 months ago

1.0.10

7 months ago

1.0.9

7 months ago

1.0.8

7 months ago

1.0.7

7 months ago

1.0.6

7 months ago

1.0.5

7 months ago

1.0.4

7 months ago

1.0.3

7 months ago

1.0.2

7 months ago

1.0.1

7 months ago

1.0.0

7 months ago