Compare commits

...

4 Commits

Author SHA1 Message Date
Andres Aya
00eb5b10e7 Merge e5303d7ea0 into 8557d4f3d8 2023-07-15 22:00:04 -05:00
Julien Le Coupanec
8557d4f3d8 Merge pull request #337 from phaneendra24/adding-js-arrayMethod
adding the at() method
2023-07-11 12:20:48 +02:00
phaneendra
f8d75a7ccf adding the at method 2023-07-07 16:49:20 +05:30
Andres Aya
e5303d7ea0 add example spread operator 2023-04-14 22:23:55 -05:00
2 changed files with 6 additions and 0 deletions

View File

@@ -72,6 +72,7 @@ array.splice(start, deleteCount, item1, item2, ...) // Adds and/or removes elem
arr.unshift([element1[, ...[, elementN]]]) // Adds one or more elements to the front of an array and returns the new length of the array.
// Instance: accessor methods
arr.at(index) // Returns the element at the specified index in the array.
arr.concat(value1[, value2[, ...[, valueN]]]) // Returns a new array comprised of this array joined with other array(s) and/or value(s).
arr.includes(searchElement, fromIndex) // Determines whether an array contains a certain element, returning true or false as appropriate.
arr.indexOf(searchElement[, fromIndex]) // Returns the first (least) index of an element within the array equal to the specified value, or -1 if none is found.

View File

@@ -602,3 +602,8 @@ echo $host; // domain-name.com
$text = "A regular expression (shortened as regex) is a sequence of characters that define a search pattern. Usually such patterns are used by string-searching algorithms for 'find' or 'find and replace' operations on strings, or for input validation.";
$text = preg_replace("/\b(regex)\b/i", 'replaced content', $text);
echo $text; /*A regular expression (shortened as replaced content) is a sequence of characters that define a search pattern. Usually such patterns are used by string-searching algorithms for 'find' or 'find and replace' operations on strings, or for input validation.*/
// spread operator > PHP 7.4
$array1 = [1, 2, 3];
$array2 = [4, 5, 6];
$merge_array = [0, ...$array1, ...$array2]; // [0, 1, 2, 3, 4, 5, 6]