

beginning is the index of where you want to begin extraction on your string (reminder: always start at 0).slice is the name of the method you are using.stringName refers to the name of the string variable you want to use the slice() function on.Altogether, the syntax looks like the keywords below: All you need is the beginning index of where you want to start extracting, and the ending syntax for the ending of the word or phrase you want to extract.

Using the js slice (JavaScript Slice) method for a string is simple. You only want to extract the first word in this string for your website, which in this case is “Big”. You have a website that you are designing that randomly generates names for people based off a bunch of random strings. For example, say you have a string called ‘boatName’ and it has a value of “Big Bertha”. The JavaScript Slice method allows users to extract a specified part of a string and returns the value extracted. Array in JavaScript || Full-Stack Web-Development Course #24 What Does Javascript Slice Do?
