or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

array-functions.mdcollection-functions.mdfunction-utilities.mdindex.mdobject-functions.mdtype-checking.md
tile.json

type-checking.mddocs/

0

# Type Checking (Lang)

1

2

Comprehensive type checking utilities for runtime type validation and detection. These functions provide reliable type checking that handles JavaScript's quirks and edge cases.

3

4

## Capabilities

5

6

### IsArray

7

8

Checks if value is classified as an Array object.

9

10

```javascript { .api }

11

/**

12

* Checks if `value` is classified as an `Array` object.

13

*

14

* @param {*} value The value to check.

15

* @returns {boolean} Returns `true` if `value` is correctly classified, else `false`.

16

*/

17

function isArray(value);

18

```

19

20

**Usage Examples:**

21

22

```javascript

23

var isArray = require('lodash.isarray');

24

25

isArray([1, 2, 3]);

26

// => true

27

28

isArray(document.body.children);

29

// => false

30

31

isArray('abc');

32

// => false

33

34

isArray(function() { return arguments; }());

35

// => false

36

```

37

38

### IsObject

39

40

Checks if value is the language type of Object.

41

42

```javascript { .api }

43

/**

44

* Checks if `value` is the language type of `Object`.

45

* (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)

46

*

47

* @param {*} value The value to check.

48

* @returns {boolean} Returns `true` if `value` is an object, else `false`.

49

*/

50

function isObject(value);

51

```

52

53

**Usage Examples:**

54

55

```javascript

56

var isObject = require('lodash.isobject');

57

58

isObject({});

59

// => true

60

61

isObject([1, 2, 3]);

62

// => true

63

64

isObject(function() {});

65

// => true

66

67

isObject(null);

68

// => false

69

```

70

71

### IsString

72

73

Checks if value is classified as a String primitive or object.

74

75

```javascript { .api }

76

/**

77

* Checks if `value` is classified as a `String` primitive or object.

78

*

79

* @param {*} value The value to check.

80

* @returns {boolean} Returns `true` if `value` is correctly classified, else `false`.

81

*/

82

function isString(value);

83

```

84

85

**Usage Examples:**

86

87

```javascript

88

var isString = require('lodash.isstring');

89

90

isString('abc');

91

// => true

92

93

isString(1);

94

// => false

95

```

96

97

### IsNumber

98

99

Checks if value is classified as a Number primitive or object.

100

101

```javascript { .api }

102

/**

103

* Checks if `value` is classified as a `Number` primitive or object.

104

*

105

* **Note:** To exclude `Infinity`, `-Infinity`, and `NaN`, which are classified

106

* as numbers, use the `_.isFinite` method.

107

*

108

* @param {*} value The value to check.

109

* @returns {boolean} Returns `true` if `value` is correctly classified, else `false`.

110

*/

111

function isNumber(value);

112

```

113

114

**Usage Examples:**

115

116

```javascript

117

var isNumber = require('lodash.isnumber');

118

119

isNumber(3);

120

// => true

121

122

isNumber(Number.MIN_VALUE);

123

// => true

124

125

isNumber(Infinity);

126

// => true

127

128

isNumber('3');

129

// => false

130

```

131

132

### IsBoolean

133

134

Checks if value is classified as a Boolean primitive or object.

135

136

```javascript { .api }

137

/**

138

* Checks if `value` is classified as a `Boolean` primitive or object.

139

*

140

* @param {*} value The value to check.

141

* @returns {boolean} Returns `true` if `value` is correctly classified, else `false`.

142

*/

143

function isBoolean(value);

144

```

145

146

**Usage Examples:**

147

148

```javascript

149

var isBoolean = require('lodash.isboolean');

150

151

isBoolean(false);

152

// => true

153

154

isBoolean(null);

155

// => false

156

```

157

158

### IsFunction

159

160

Checks if value is classified as a Function object.

161

162

```javascript { .api }

163

/**

164

* Checks if `value` is classified as a `Function` object.

165

*

166

* @param {*} value The value to check.

167

* @returns {boolean} Returns `true` if `value` is correctly classified, else `false`.

168

*/

169

function isFunction(value);

170

```

171

172

**Usage Examples:**

173

174

```javascript

175

var isFunction = require('lodash.isfunction');

176

177

isFunction(function() {});

178

// => true

179

180

isFunction(/abc/);

181

// => false

182

```

183

184

### IsDate

185

186

Checks if value is classified as a Date object.

187

188

```javascript { .api }

189

/**

190

* Checks if `value` is classified as a `Date` object.

191

*

192

* @param {*} value The value to check.

193

* @returns {boolean} Returns `true` if `value` is correctly classified, else `false`.

194

*/

195

function isDate(value);

196

```

197

198

**Usage Examples:**

199

200

```javascript

201

var isDate = require('lodash.isdate');

202

203

isDate(new Date);

204

// => true

205

206

isDate('Mon April 23 2012');

207

// => false

208

```

209

210

### IsEmpty

211

212

Checks if value is an empty object, collection, map, or set.

213

214

```javascript { .api }

215

/**

216

* Checks if `value` is an empty object, collection, map, or set.

217

*

218

* Objects are considered empty if they have no own enumerable string keyed

219

* properties.

220

*

221

* Array-like values such as `arguments` objects, arrays, buffers, strings, or

222

* jQuery-like collections are considered empty if they have a `length` of `0`.

223

* Similarly, maps and sets are considered empty if they have a `size` of `0`.

224

*

225

* @param {*} value The value to check.

226

* @returns {boolean} Returns `true` if `value` is empty, else `false`.

227

*/

228

function isEmpty(value);

229

```

230

231

**Usage Examples:**

232

233

```javascript

234

var isEmpty = require('lodash.isempty');

235

236

isEmpty(null);

237

// => true

238

239

isEmpty(true);

240

// => true

241

242

isEmpty(1);

243

// => true

244

245

isEmpty([1, 2, 3]);

246

// => false

247

248

isEmpty({ a: 1 });

249

// => false

250

```

251

252

### IsEqual

253

254

Performs a deep comparison between two values to determine if they are equivalent.

255

256

```javascript { .api }

257

/**

258

* Performs a deep comparison between two values to determine if they are

259

* equivalent.

260

*

261

* **Note:** This method supports comparing arrays, array buffers, booleans,

262

* date objects, error objects, maps, numbers, `Object` objects, regexes,

263

* sets, strings, symbols, and typed arrays.

264

*

265

* @param {*} value The value to compare.

266

* @param {*} other The other value to compare.

267

* @returns {boolean} Returns `true` if the values are equivalent, else `false`.

268

*/

269

function isEqual(value, other);

270

```

271

272

**Usage Examples:**

273

274

```javascript

275

var isEqual = require('lodash.isequal');

276

277

var object = { a: 1 };

278

var other = { a: 1 };

279

280

isEqual(object, other);

281

// => true

282

283

object === other;

284

// => false

285

```

286

287

### IsNull

288

289

Checks if value is null.

290

291

```javascript { .api }

292

/**

293

* Checks if `value` is `null`.

294

*

295

* @param {*} value The value to check.

296

* @returns {boolean} Returns `true` if `value` is `null`, else `false`.

297

*/

298

function isNull(value);

299

```

300

301

**Usage Examples:**

302

303

```javascript

304

var isNull = require('lodash.isnull');

305

306

isNull(null);

307

// => true

308

309

isNull(void 0);

310

// => false

311

```

312

313

### IsUndefined

314

315

Checks if value is undefined.

316

317

```javascript { .api }

318

/**

319

* Checks if `value` is `undefined`.

320

*

321

* @param {*} value The value to check.

322

* @returns {boolean} Returns `true` if `value` is `undefined`, else `false`.

323

*/

324

function isUndefined(value);

325

```

326

327

**Usage Examples:**

328

329

```javascript

330

var isUndefined = require('lodash.isundefined');

331

332

isUndefined(void 0);

333

// => true

334

335

isUndefined(null);

336

// => false

337

```

338

339

### IsNaN

340

341

Checks if value is NaN.

342

343

```javascript { .api }

344

/**

345

* Checks if `value` is `NaN`.

346

*

347

* **Note:** This method is based on [`Number.isNaN`](https://mdn.io/Number/isNaN)

348

* and is not the same as global [`isNaN`](https://mdn.io/isNaN) which returns

349

* `true` for `undefined` and other non-number values.

350

*

351

* @param {*} value The value to check.

352

* @returns {boolean} Returns `true` if `value` is `NaN`, else `false`.

353

*/

354

function isNaN(value);

355

```

356

357

**Usage Examples:**

358

359

```javascript

360

var isNaN = require('lodash.isnan');

361

362

isNaN(NaN);

363

// => true

364

365

isNaN(new Number(NaN));

366

// => true

367

368

isNaN(undefined);

369

// => false

370

```

371

372

### IsFinite

373

374

Checks if value is a finite primitive number.

375

376

```javascript { .api }

377

/**

378

* Checks if `value` is a finite primitive number.

379

*

380

* **Note:** This method is based on [`Number.isFinite`](https://mdn.io/Number/isFinite).

381

*

382

* @param {*} value The value to check.

383

* @returns {boolean} Returns `true` if `value` is a finite number, else `false`.

384

*/

385

function isFinite(value);

386

```

387

388

**Usage Examples:**

389

390

```javascript

391

var isFinite = require('lodash.isfinite');

392

393

isFinite(3);

394

// => true

395

396

isFinite(Number.MAX_VALUE);

397

// => true

398

399

isFinite(3.14);

400

// => true

401

402

isFinite(Infinity);

403

// => false

404

```

405

406

## Additional Functions

407

408

The type checking category also includes: `isArguments`, `isElement`, `isError`, `isMatch`, `isNative`, `isPlainObject`, `isRegExp`, `isTypedArray`

409

410

**Package Installation:**

411

412

```bash

413

npm install lodash.isarray lodash.isobject lodash.isstring lodash.isnumber

414

npm install lodash.isboolean lodash.isfunction lodash.isdate lodash.isempty

415

npm install lodash.isequal lodash.isnull lodash.isundefined lodash.isnan

416

npm install lodash.isfinite

417

```