Is there a method in javascript that does the same thing as windows in rust?
I want to iterate over an array in js comparing 2 values each time like you can with windows() in rust but not sure if there is a method for this.
Anyone know a method or a similar way to recreate it?
windows() example:
let slice = ['r', 'u', 's', 't'];
let mut iter = slice.windows(2);
assert_eq!(iter.next().unwrap(), &['r', 'u']);
assert_eq!(iter.next().unwrap(), &['u', 's']);
assert_eq!(iter.next().unwrap(), &['s', 't']);
assert!(iter.next().is_none());