Created
January 17, 2022 15:46
-
-
Save K-Vishwak/eb3a2416372f6bfd48fd2a7be46d9b73 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const str = 'Welcome to vkglobal just code'; | |
// copies entire string. | |
str.slice(); | |
> 'Welcome to vkglobal just code' | |
// between indexes. Count spaces too. | |
str.slice(11,19); | |
> 'vkglobal' | |
// index greater than string length; | |
str.slice(30); | |
> '' | |
// offset from last index. e -> -1, d -> -2 ... | |
str.slice(-9); | |
> 'just code' | |
// negative range. | |
str.slice(-9, -5); | |
> 'just' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment