JS Error: <parameter>.contains is not a function, not sure why

JS Error: <parameter>.contains is not a function, not sure why

我一直在写一些JavaScript代码,并介绍了这个小功能:

function decodeLink(thelink) {
    console.log(typeof(thelink)); // Reports 'string'

    if (thelink.contains("something")) {
        // Cool condition
    }
}

但是,如果我要调用 decodeLink("hello");,我会收到此错误:

TypeError: thelink.contains is not a function

请注意,我使用的是 node.js 和 discord.js,但是评论导入不会产生任何结果。

我一直在使用强类型的 C# 编程风格,这种弱类型对我来说很陌生。我确信我错过了一些重要的东西(比如一些明确的方式告诉程序它正在处理一个字符串),但是没有搜索让我更接近什么...

你需要的方法叫includes不包含

function decodeLink(thelink) {
    console.log(typeof(thelink)); // Reports 'string'

    if (thelink.includes("something")) {
        // Cool condition
    }
}