js find space in string

JavaScript
if(str.indexOf(' ') >= 0){
    console.log("contains spaces");
}
Source

Also in JavaScript: