Javascript check if parameter contain this keyword [closed]

If you’re trying to match the string(wrap the text inside single/double quote). Use the below code.

function check(el) {

    if (el === 'this') {
        alert("contain!");
        return el;
    } else {
        alert("not contain this keyword");
    }
}

check('this');

Leave a Comment