Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7967395
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T06:41:10+00:00 2026-06-04T06:41:10+00:00

Is there a function in javascript that compares a string and returns a boolean?

  • 0

Is there a function in javascript that compares a string and returns a boolean? I found .match but it returns the strings that matched. I was hoping there was something else so that I would have a lesser code in comparing a string. Since I wanted to check if a string has this word and proceed else not.

thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T06:41:11+00:00Added an answer on June 4, 2026 at 6:41 am

    You may use type augmentation, especially if you need to use this function often:

    String.prototype.isMatch = function(s){
       return this.match(s)!==null 
    }
    

    So you can use:

    var myBool = "ali".isMatch("Ali");
    

    General view is that use of type augmentation is discouraged only because of the fact that it can collide with other augmentations.

    According to Javascript Patterns book, its use must be limited.

    I personally think it is OK, as long as you use a good naming such as:

    String.prototype.mycompany_isMatch = function(s){
       return this.match(s)!==null 
    }
    

    This will make it ugly but safe.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In Javascript is there a function that returns the number of times that a
Is there a javascript function that returns the date that a specified file was
Is there a javascript function that takes a string and converts it into another
Possible Duplicate: Is there a JavaScript function that can pad a string to get
I would like a function that compares to arrays of javascript strings, and saving
Is there any javascript function that can encrypt data: For example i want to
I have a javascript function that checks for a date range. Is there any
I have a javascript function that runs every 3 seconds, is there any way
Is there any way that I can call a JavaScript function via css? For
Is there a jquery/javascript function that does the same that PHP echo() ?

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.