mirror of
https://github.com/adambard/learnxinyminutes-docs.git
synced 2025-08-06 06:47:54 +02:00
Comments improved
This commit is contained in:
@@ -186,7 +186,7 @@ someVar = myArray.shift(); // Remove first element and return it
|
|||||||
myArray.push(3); // Add as the last element
|
myArray.push(3); // Add as the last element
|
||||||
someVar = myArray.pop(); // Remove last element and return it
|
someVar = myArray.pop(); // Remove last element and return it
|
||||||
|
|
||||||
// Join all elements of an array with a string
|
// Join all elements of an array with semicolon
|
||||||
var myArray0 = [32,false,"js",12,56,90];
|
var myArray0 = [32,false,"js",12,56,90];
|
||||||
myArray0.join(";") // = "32;false;js;12;56;90"
|
myArray0.join(";") // = "32;false;js;12;56;90"
|
||||||
|
|
||||||
@@ -194,8 +194,9 @@ myArray0.join(";") // = "32;false;js;12;56;90"
|
|||||||
myArray0.slice(1,4); // = [false,"js",12]
|
myArray0.slice(1,4); // = [false,"js",12]
|
||||||
|
|
||||||
// Remove 4 elements starting from index 2, and insert there strings
|
// Remove 4 elements starting from index 2, and insert there strings
|
||||||
// "33","34" and "35"; return removed subarray
|
// "hi","wr" and "ld"; return removed subarray
|
||||||
myArray0.splice(2,4,"33","34","35");
|
myArray0.splice(2,4,"hi","wr","ld"); // = ["js",12,56,90]
|
||||||
|
// myArray0 === [32,false,"hi","wr","ld"]
|
||||||
|
|
||||||
// JavaScript's objects are equivalent to "dictionaries" or "maps" in other
|
// JavaScript's objects are equivalent to "dictionaries" or "maps" in other
|
||||||
// languages: an unordered collection of key-value pairs.
|
// languages: an unordered collection of key-value pairs.
|
||||||
|
Reference in New Issue
Block a user