Avoid "null" with match() - Javascript RegExp

Javascript examples for RegExp:RegExp Match

Description

Avoid "null" with match()

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
      <script type="text/javascript">
    window.onload=function(){//from w w w .ja  v a 2  s  . c o  m
function checkMediaQueries(cssText) {
    return cssText.match(/@media/gi) ? true : false;
}
console.log( checkMediaQueries('nonsense') );
console.log( checkMediaQueries('@media all and more') );
    }

      </script> 
   </head> 
   <body>  
   </body>
</html>

Related Tutorials