const streetAddress = addy.substring(0, addy.indexOf(","));

While it’s not the best place for definitive information on what each method does (MDN Web Docs are better for that) W3Schools.com is good for introducing you to syntax.

Answer from wheresrhys on Stack Overflow
🌐
Futurestud.io
futurestud.io › tutorials › get-the-part-before-first-occurrence-in-a-string-in-javascript-or-node-js
Get the Part Before First Occurrence in a String in JavaScript or Node.js
before('Future Studio is an awesome island', 'is') // 'Future Studio ' before('Future Studio is an awesome island', 'great') // 'Future Studio is an awesome island' before('Future Studio') // 'Future Studio'
🌐
W3Schools
w3schools.com › jsref › jsref_substring.asp
JavaScript String substring() Method
The substring() method extracts characters from start to end (exclusive).
🌐
Logfetch
logfetch.com › js-get-substring-before-char
How to Get the Substring Before a Character in JavaScript - LogFetch
str = str.substring(0, str.indexOf(":")); str.indexOf(":") returns 4, so we are obtaining the string from index 0 (inclusive) to 4 (exclusive). str = /(.+):/.exec(str)[0]; (.+) matches any number of word characters. : matches, well, a colon. How to Validate a UUID with Regular Expressions in JavaScript ·
Find elsewhere
🌐
Futurestud.io
futurestud.io › tutorials › get-the-part-before-last-occurrence-in-a-string-in-javascript-or-node-js
Get the Part Before Last Occurrence in a String in JavaScript or Node.js
/** * Returns the portion of the string before the last occurrence of the given `delimiter`. * * @param {String} delimiter * * @returns {String} */ function beforeLast (value, delimiter) { value = value || '' if (delimiter === '') { return value } const substrings = value.split(delimiter) return substrings.length === 1 ? value // delimiter is not part of the string : substrings.slice(0, -1).join(delimiter) } Notice: splitting a string for an empty delimiter creates an array of the string value’s characters.
🌐
Linux Hint
linuxhint.com › get-substring-before-specific-character-javascript
Get the Substring Before a Specific Character in JavaScript
Linux Hint LLC, [email protected] 1210 Kelly Park Circle, Morgan Hill, CA 95037 Privacy Policy and Terms of Use
🌐
Futurestud.io
futurestud.io › tutorials › get-the-part-before-a-character-in-a-string-in-javascript-or-node-js
Get the Part Before a Character in a String in JavaScript or Node.js
const Str = require('@supercharge/strings') Str('A1:L200').before(':').get() // 'A1' Str('2020-this-is-a-tutorial-slug').before('-').get() // '2020'
🌐
Dirask
dirask.com › posts › TypeScript-get-substring-before-character-pJAMoD
TypeScript - get substring before character
const character: string = ':'; const string: string = 'user:password'; const index: number = string.indexOf(character); const substring: string = string.substring(0, index); console.log(substring); // user · In this example, we create a reusable function that helps to get the substring before indicated character.
🌐
Bobby Hadz
bobbyhadz.com › blog › javascript-get-substring-after-specific-character
Get the Substring after a specific Character in JavaScript | bobbyhadz
Use the split() method to split the string on the character. Access the array of strings at index 1. The first element in the array is the substring after the character.
🌐
MarkLogic
docs.marklogic.com › fn:substring-before
fn:substring-before — MarkLogic 12 Product Documentation
JavaScript fn.substringBefore · fn:substring-before( $input as xs:string?, $before as xs:string?, [$collation as xs:string] ) as xs:string? Returns the substring created by taking all of the input characters that occur before the specified $before characters.
🌐
W3Schools
w3schools.com › jsref › jsref_substr.asp
JavaScript String substr() Method
The substr() method begins at a specified position, and returns a specified number of characters.
🌐
Refine
refine.dev › home › blog › tutorials › javascript substring method
JavaScript Substring Method | Refine
December 31, 2024 - When we pass both the startIndex and endIndex, we get a substring of characters in startIndex <= str < endIndex range: const mnemonic = "Please, send, cats, monkeys, and, zebras, in, large, cages, make, sure, padlocked."; console.log(mnemonic.substring(14, 27)); // "cats, monkeys" This means, now we end up with a substring that ends before the endIndex.