Check if the string is binary number in Javascript

Method 1

//check if the string is binary number
//return true or false
function isBinary(input) {
	for (i = 0; i < input.length; i++) {
		if ((input.charAt(i)!='1')&amp;&amp;(input.charAt(i) !='0')){
			return false;
		}
	}
	return true;
}

Method 2

function isBinary(input) {
 	return = input.matches("^[01]+$");
}