Wednesday, January 21, 2015

Some javascript stuff that existed in javasciprt



Today I learned again another trick using javascript

Problem : check if the string passed the regex , if yes execute the function

you can solve it these way

these will return false
/d/.test("kevin") && (function(){console.log('aw')})()

if you want it to execute
/kevin/g.test("kevin") && (function(){console.log('aw')})()


No comments:

Post a Comment