Skip to content

Commit d6f7cb9

Browse files
authored
Adds Array#includes and Array#slice
JS has an `includes` method on arrays instead of the deprecated `indexOf() === -1`, and `drop` works like `slice` (theoretically `.dropRight(n)` == `.slice(0, -n)`)
1 parent 9f54e19 commit d6f7cb9

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

doc/sjs-for-js/es6-to-scala-part2.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,15 +194,15 @@ shown with examples in the code block below.
194194
{% highlight scala %}
195195
val seq = Seq(1, 2, 3, 4, 5)
196196
seq.isEmpty == false
197-
seq.contains(6) == false // JS Array.indexOf(6) == -1
197+
seq.contains(6) == false // JS Array.includes()
198198
seq.forall(x => x > 0) == true // JS Array.every()
199199
seq.exists(x => x % 3 == 0) == true // JS Array.some()
200200
seq.find(x => x > 3) == Some(4) // JS Array.find()
201201
seq.head == 1
202202
seq.tail == Seq(2, 3, 4, 5)
203203
seq.last == 5
204204
seq.init == Seq(1, 2, 3, 4)
205-
seq.drop(2) == Seq(3, 4, 5)
205+
seq.drop(2) == Seq(3, 4, 5) // JS Array.slice()
206206
seq.dropRight(2) == Seq(1, 2, 3)
207207
seq.count(x => x < 3) == 2
208208
seq.groupBy(x => x % 2) == Map(1 -> Seq(1, 3, 5), 0 -> Seq(2, 4))

0 commit comments

Comments
 (0)