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
Discussions

How do I have JavaScript get a substring before a character? - Stack Overflow
Let's say I have a paragraph that says 55+5. I want to have JavaScript return everything before the plus. Is this possible using substrings? More on stackoverflow.com
🌐 stackoverflow.com
javascript - Extract substring of a string before specific character - Stack Overflow
I have this string 2022-04-01T09:00 I want to get rid of anything after letter T I can explode it based on the letter T, and access the first element to get this 2022-04-01. I wonder if there is a ... More on stackoverflow.com
🌐 stackoverflow.com
jquery - javascript get string before a character - Stack Overflow
or if you prefer raw javascript : http://jsfiddle.net/snrobot/XsuQd/ ... var beforeQuote = _.substrBefore("'"); var hasQuote = beforeQuote("14' - €0.88"); // hasQuote = "14'" var noQoute = beforeQuote("14 €0.88"); // noQuote = "" ... I purposely chose to leave the search character in the ... More on stackoverflow.com
🌐 stackoverflow.com
August 26, 2012
javascript - get string before and after specific character - Stack Overflow
I want to split a string for a fill in string type with no whitespace for examples: £____ ____$ 42____$ i would like a way to split the string so i can know what the characters before and after _. More on stackoverflow.com
🌐 stackoverflow.com
🌐
W3Schools
w3schools.com › jsref › jsref_substring.asp
JavaScript String substring() Method
The substring() method extracts characters from start to end (exclusive).
🌐
Flavio Copes
flaviocopes.com › home › javascript › javascript, how to get string until character
JavaScript, how to get string until character - Flavio Copes
July 24, 2022 - Learn how to get the part of a string before a specific character in JavaScript using split, a quick one-liner that returns everything up to that point.
🌐
Python Examples
pythonexamples.org › javascript › how-to-get-substring-before-specific-character
How to get Substring before Specific Character in JavaScript
To get the substring before a specific character in JavaScript, you can use the `substring` method along with the `indexOf` method to find the position of the character.
🌐
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
February 3, 2022 - 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'
Find elsewhere
🌐
Tutorial Reference
tutorialreference.com › javascript › examples › faq › javascript-how-to-get-substring-before-a-character
How to Get the Substring Before a Specific Character in JavaScript | Tutorial Reference
Use String.prototype.split(char) to break the string into an array of substrings, using the character as the delimiter. Take the first element of the resulting array at index 0. ... While highly readable, this method can be slightly less performant on very long strings because it has to process ...
🌐
TutorialsPoint
tutorialspoint.com › article › how-to-get-a-part-of-string-after-a-specified-character-in-javascript
How to get a part of string after a specified character in JavaScript?
March 15, 2026 - To get a part of a string after a specified character in JavaScript, you can use the substring() method combined with indexOf(). This technique allows you to extract portions of text before or after any character.
🌐
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'
🌐
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
February 17, 2022 - /** * 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.
🌐
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.
🌐
Refine
refine.dev › home › blog › tutorials › javascript substring method
JavaScript Substring Method | Refine
January 1, 2025 - 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.
🌐
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.