summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorname <you@example.org>2017-11-13 00:41:52 +0300
committername <you@example.org>2017-11-13 00:41:52 +0300
commitaff623e234d8d0844a44ff5331d756ae539aa6d0 (patch)
treeb6af740556662cdda8cd7ba469f64f52d44491bb
parentcbb09c2df6fe9b373457c3b59380038e85f00e92 (diff)
Comments improved
-rw-r--r--javascript.html.markdown7
1 files changed, 4 insertions, 3 deletions
diff --git a/javascript.html.markdown b/javascript.html.markdown
index 75bdf1ad..199c3c09 100644
--- a/javascript.html.markdown
+++ b/javascript.html.markdown
@@ -186,7 +186,7 @@ someVar = myArray.shift(); // Remove first element and return it
myArray.push(3); // Add as the last element
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];
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]
// Remove 4 elements starting from index 2, and insert there strings
-// "33","34" and "35"; return removed subarray
-myArray0.splice(2,4,"33","34","35");
+// "hi","wr" and "ld"; return removed subarray
+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
// languages: an unordered collection of key-value pairs.