Dylan Thepiguy
Dylan Thepiguy

Reputation: 43

Javascript how do you use the / symbol

What is the best way to detect a mobile device in jQuery?

i found this and i was wondered what the / sign meant in the if( /Android|webOS|iPhone|iPad|iPod|BlackBerry/i.test(navigator.userAgent) ) { // some code.. } code.

Upvotes: 0

Views: 59

Answers (1)

Rainulf
Rainulf

Reputation: 341

It's regular expression.

/Android|webOS|iPhone|iPad|iPod|BlackBerry/i.test(navigator.userAgent)

It returns true if navigator.userAgent contains the pattern above.

Upvotes: 1

Related Questions