Skip to content
  • home
  • portfolio
  • web design journal
  • blog
    • adventure
    • san diego
    • projects
    • website design
Blog Quickbits Javascript Does String Contain Substring

Javascript Does String Contain Substring

By Forrest Smith - Drempd.com

var str = "Some haystack text goes here that contains needlestring";

  str.includes('needlestring');




If you get an error, like "TypeError: e.includes is not a function", it probably means that you're trying to do a search on something that isn't a string or an array.   Fix this by converting the variable to a string, like:



element.toString().includes("#");

Posted on August 27, 2022October 2, 2022 in Quickbits
  • Adventure

    • adventure
    • gravelgrinding
    • hiking
    • running
  • The Built Environment

    • architecture
    • urbanity
  • Locations

    • san diego
    • portland
  • Freelance Life

    • freelancing
    • productivity
  • Web Dev

    • css
    • entrepreneurship
    • git
    • handlebars
    • html
    • inkscape
    • photoshop
    • php
    • sass
    • web design
    • web development
    • saphire

drempd | san diego, ca


home contact

adventures san diego urbanity and architecture projects stream website design

portfolio resume san diego web design freelance web designer

custom web design responsive web design website maintenance