Global

Methods

array_keys(haystack)

get all keys

Parameters:
Name Type Description
haystack

string etc

array_rand(arrays, unique)

pick random from array

Parameters:
Name Type Description
arrays Array.<any>
unique boolean

Unique the arrays

array_shuffle(a)

Shuffles array in place.

Parameters:
Name Type Description
a

items An array containing the items.

array_split_chunks(sourceArray, chunkSize)

split array to chunks

Parameters:
Name Type Description
sourceArray
chunkSize
Returns:
See:
Example
let ar1 = [
  1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20
];
// split array by 4
console.log("Split in chunks with 4 size", splitChunks(ar1, 4)); // [[1,2,3,4], [5,6,7,8]...]

array_unique(arrays)

Array unique

Parameters:
Name Type Description
arrays Array.<any>

array_unset(arrayName, key)

Unset array

Parameters:
Name Type Description
arrayName Array.<any>
key String | number

deepAssign(…objects)

Deep merge two or more objects into the first. (c) 2021 Chris Ferdinandi, MIT License, https://gomakethings.com

Parameters:
Name Type Attributes Description
objects <repeatable>

The objects to merge together

Returns:
-

Merged values of defaults and options

getAllMethods(toCheck)

Get all method from class

Parameters:
Name Type Description
toCheck
Returns:

inArray(needle, haystack)

in_array PHP equivalent

Parameters:
Name Type Description
needle

string etc

haystack

in_array(needle, haystack)

in_array PHP equivalent

Parameters:
Name Type Description
needle

string etc

haystack

isFloat(n)

is variable float?

Parameters:
Name Type Description
n
Returns:

isInt(n)

is variable number?

Parameters:
Name Type Description
n
Returns:

isObject(item)

Simple object check.

Parameters:
Name Type Description
item
Returns:
Example
```js
console.log(isObject({a:'a'})); // true
console.log(isObject(['a','b'])); // false
```

isObjectWritable(obj, key)

is Object Writable?

Parameters:
Name Type Description
obj
key
Returns:

mergeDeep(target)

Deep merge two objects.

Parameters:
Name Type Description
target
...sources
See:

object_join(obj, separator)

Join object to separated string

  • [].join() equivalent
Parameters:
Name Type Default Description
obj

Object

separator ,

default comma(,)

Returns:
-

Joined string

oddoreven(n, type)

Odd or Even (Ganjil Genap);

Parameters:
Name Type Description
n
type

odd or even

removeItem(arr, value)

Remove item from array

Parameters:
Name Type Description
arr
value
Returns:

runOnce(fn)

Run the function only once

Parameters:
Name Type Description
fn
Returns:
See:

shuffle(array)

PHP shuffle array equivalent

Parameters:
Name Type Description
array
Example
var arr = [2, 11, 37, 42];
shuffle(arr);
console.log(arr); //return random

strMatch(str, pattern)

easy regex match

Parameters:
Name Type Description
str
pattern
Returns:

strpad(val)

strpad / startwith zero [0]

Parameters:
Name Type Description
val number