javascript string slice vs splice code example

Example 1: javascript substring vs slice

The same except:
* if start > stop substring swaps the arguments, slice returns ""
* if argument is NaN or negative, substring will treat it as a 0
* if start is negative, slice sets char from the end of string
* if stop is negative, slice sets stop to string.lengthMath.abs(stop)

Example 2: js string slicing

const str = 'The quick brown fox jumps over the lazy dog.';

console.log(str.slice(31));
// expected output: "the lazy dog."

console.log(str.slice(4, 19));
// expected output: "quick brown fox"