0
# Environment Detection
1
2
Browser and device detection functions for responsive behavior and feature detection. These functions are only available in browser environments.
3
4
## Capabilities
5
6
### Browser Detection
7
8
#### Chrome Check
9
10
Checks if the current browser is Chrome with optional version range.
11
12
```javascript { .api }
13
/**
14
* Checks if current browser is chrome
15
* @param range - Optional version range (string or number)
16
* @returns True if current browser is Chrome
17
* Interfaces: not
18
*/
19
function chrome(range?: string | number): boolean;
20
```
21
22
**Usage Example:**
23
24
```javascript
25
is.chrome(); // true if current browser is chrome
26
is.not.chrome(); // false if current browser is chrome
27
is.chrome(50); // true if current version of chrome is 50
28
is.chrome('>=40'); // true if current version of chrome is >= 40
29
is.not.chrome('<30'); // true if current version is not < 30
30
```
31
32
#### Firefox Check
33
34
Checks if the current browser is Firefox with optional version range.
35
36
```javascript { .api }
37
/**
38
* Checks if current browser is firefox
39
* @param range - Optional version range (string or number)
40
* @returns True if current browser is Firefox
41
* Interfaces: not
42
*/
43
function firefox(range?: string | number): boolean;
44
```
45
46
**Usage Example:**
47
48
```javascript
49
is.firefox(); // true if current browser is firefox
50
is.firefox(41); // true if current version of firefox is 41
51
is.firefox('>=40'); // true if current version is >= 40
52
is.not.firefox('<30'); // true if current version is not < 30
53
```
54
55
#### Internet Explorer Check
56
57
Checks if the current browser is Internet Explorer with optional version range.
58
59
```javascript { .api }
60
/**
61
* Checks if current browser is ie
62
* @param range - Optional version range (string or number)
63
* @returns True if current browser is Internet Explorer
64
* Interfaces: not
65
*/
66
function ie(range?: string | number): boolean;
67
```
68
69
**Usage Example:**
70
71
```javascript
72
is.ie(); // true if current browser is ie
73
is.ie(10); // true if current version of ie is 10
74
is.ie('>=10'); // true if current version is >= 10
75
is.not.ie('<9'); // true if current version is not < 9
76
```
77
78
#### Edge Check
79
80
Checks if the current browser is Microsoft Edge with optional version range.
81
82
```javascript { .api }
83
/**
84
* Checks if current browser is edge
85
* @param range - Optional version range (string or number)
86
* @returns True if current browser is Edge
87
* Interfaces: not
88
*/
89
function edge(range?: string | number): boolean;
90
```
91
92
**Usage Example:**
93
94
```javascript
95
is.edge(); // true if current browser is edge
96
is.edge(13); // true if current version of edge is 13
97
is.edge('>=12'); // true if current version is >= 12
98
is.not.edge('<13'); // true if current version is not < 13
99
```
100
101
#### Safari Check
102
103
Checks if the current browser is Safari with optional version range.
104
105
```javascript { .api }
106
/**
107
* Checks if current browser is safari
108
* @param range - Optional version range (string or number)
109
* @returns True if current browser is Safari
110
* Interfaces: not
111
*/
112
function safari(range?: string | number): boolean;
113
```
114
115
**Usage Example:**
116
117
```javascript
118
is.safari(); // true if current browser is safari
119
is.safari(9); // true if current version of safari is 9
120
is.safari('>=8'); // true if current version is >= 8
121
is.not.safari('<7'); // true if current version is not < 7
122
```
123
124
#### Opera Check
125
126
Checks if the current browser is Opera with optional version range.
127
128
```javascript { .api }
129
/**
130
* Checks if current browser is opera
131
* @param range - Optional version range (string or number)
132
* @returns True if current browser is Opera
133
* Interfaces: not
134
*/
135
function opera(range?: string | number): boolean;
136
```
137
138
**Usage Example:**
139
140
```javascript
141
is.opera(); // true if current browser is opera
142
is.opera(36); // true if current version of opera is 36
143
is.opera('>=35'); // true if current version is >= 35
144
is.not.opera('<20'); // true if current version is not < 20
145
```
146
147
#### PhantomJS Check
148
149
Checks if the current browser is PhantomJS with optional version range.
150
151
```javascript { .api }
152
/**
153
* Checks if current browser is phantomjs
154
* @param range - Optional version range (string or number)
155
* @returns True if current browser is PhantomJS
156
* Interfaces: not
157
*/
158
function phantom(range?: string | number): boolean;
159
```
160
161
**Usage Example:**
162
163
```javascript
164
is.phantom(); // true if current browser is phantomjs
165
is.phantom(2); // true if current version of phantom is 2
166
is.phantom('>=1'); // true if current version is >= 1
167
is.not.phantom('<2'); // true if current version is not < 2
168
```
169
170
### Device Detection
171
172
#### Mobile Device Checks
173
174
Checks for various mobile devices.
175
176
```javascript { .api }
177
/**
178
* Checks if current device is mobile
179
* @returns True if device is mobile (iPhone, iPod, Android Phone, Windows Phone, Blackberry)
180
* Interfaces: not
181
*/
182
function mobile(): boolean;
183
184
/**
185
* Checks if current device has ios
186
* @returns True if current device is iPhone, iPad or iPod
187
* Interfaces: not
188
*/
189
function ios(): boolean;
190
191
/**
192
* Checks if current device is iPhone
193
* @param range - Optional version range (string or number)
194
* @returns True if current device is iPhone
195
* Interfaces: not
196
*/
197
function iphone(range?: string | number): boolean;
198
199
/**
200
* Checks if current device is iPad
201
* @param range - Optional version range (string or number)
202
* @returns True if current device is iPad
203
* Interfaces: not
204
*/
205
function ipad(range?: string | number): boolean;
206
207
/**
208
* Checks if current device is iPod
209
* @param range - Optional version range (string or number)
210
* @returns True if current device is iPod
211
* Interfaces: not
212
*/
213
function ipod(range?: string | number): boolean;
214
```
215
216
**Usage Example:**
217
218
```javascript
219
is.mobile(); // true if current device is mobile
220
is.ios(); // true if current device is iPhone, iPad or iPod
221
is.iphone(); // true if current device is iPhone
222
is.iphone(9); // true if current iPhone version is 9
223
is.ipad(); // true if current device is iPad
224
is.ipod(); // true if current device is iPod
225
```
226
227
#### Android Device Checks
228
229
Checks for Android devices.
230
231
```javascript { .api }
232
/**
233
* Checks if current device has Android
234
* @returns True if current device has Android OS
235
* Interfaces: not
236
*/
237
function android(): boolean;
238
239
/**
240
* Checks if current device is Android phone
241
* @returns True if current device is Android phone
242
* Interfaces: not
243
*/
244
function androidPhone(): boolean;
245
246
/**
247
* Checks if current device is Android tablet
248
* @returns True if current device is Android tablet
249
* Interfaces: not
250
*/
251
function androidTablet(): boolean;
252
```
253
254
**Usage Example:**
255
256
```javascript
257
is.android(); // true if current device has Android OS
258
is.androidPhone(); // true if current device is Android phone
259
is.androidTablet(); // true if current device is Android tablet
260
```
261
262
#### Other Device Checks
263
264
Checks for other device types.
265
266
```javascript { .api }
267
/**
268
* Checks if current device is Blackberry
269
* @returns True if current device is Blackberry
270
* Interfaces: not
271
*/
272
function blackberry(): boolean;
273
274
/**
275
* Checks if current device is Windows phone
276
* @returns True if current device is Windows phone
277
* Interfaces: not
278
*/
279
function windowsPhone(): boolean;
280
281
/**
282
* Checks if current device is Windows tablet
283
* @returns True if current device is Windows tablet
284
* Interfaces: not
285
*/
286
function windowsTablet(): boolean;
287
288
/**
289
* Checks if current device is tablet
290
* @returns True if device is tablet (iPad, Android Tablet, Windows Tablet)
291
* Interfaces: not
292
*/
293
function tablet(): boolean;
294
295
/**
296
* Checks if current device is desktop
297
* @returns True if current device is desktop
298
* Interfaces: not
299
*/
300
function desktop(): boolean;
301
```
302
303
### Operating System Detection
304
305
Checks for different operating systems.
306
307
```javascript { .api }
308
/**
309
* Checks if current OS is Windows
310
* @returns True if current OS is Windows
311
* Interfaces: not
312
*/
313
function windows(): boolean;
314
315
/**
316
* Checks if current OS is Mac OS X
317
* @returns True if current OS is Mac OS X
318
* Interfaces: not
319
*/
320
function mac(): boolean;
321
322
/**
323
* Checks if current OS is linux
324
* @returns True if current OS is linux
325
* Interfaces: not
326
*/
327
function linux(): boolean;
328
```
329
330
**Usage Example:**
331
332
```javascript
333
is.windows(); // true if current OS is Windows
334
is.mac(); // true if current OS is Mac OS X
335
is.linux(); // true if current OS is linux
336
```
337
338
### Network and Feature Detection
339
340
Checks for network status and device capabilities.
341
342
```javascript { .api }
343
/**
344
* Checks if current device is online
345
* @returns True if current device is online
346
* Interfaces: not
347
*/
348
function online(): boolean;
349
350
/**
351
* Checks if current device is offline
352
* @returns True if current device is offline
353
* Interfaces: not
354
*/
355
function offline(): boolean;
356
357
/**
358
* Checks if current device supports touch
359
* @returns True if current device supports touch
360
* Interfaces: not
361
*/
362
function touchDevice(): boolean;
363
```
364
365
**Usage Example:**
366
367
```javascript
368
is.online(); // true if current device is online
369
is.offline(); // true if current device is offline
370
is.touchDevice(); // true if current device supports touch
371
```