A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://www.geeksforgeeks.org/javascript/lodash-_-isarraylike-method/ below:

Lodash _.isArrayLike() Method - GeeksforGeeks

Lodash _.isArrayLike() Method

Last Updated : 03 Sep, 2024

Lodash _.isArrayLike() method checks if the value is Array-like. A value is considered array-like if it's not a function and has a value.length that's an integer greater than or equal to 0 and less than or equal to Number.MAX_SAFE_INTEGER.

Syntax:
_.isArrayLike(value);
Parameter: Return Value:

Example 1: In this example, the lodash _.isArrayLke() method returns true for an Array.

JavaScript
// Defining Lodash variable
const _ = require('lodash');

let val = [1, 2, 3]

// Checking for an ArrayLike
console.log("The Value is ArrayLike : "
    + _.isArrayLike(val));

Output:

The Value is ArrayLike : true

Example 2: In this example, the lodash _.isArrayLke() method returns true for strings as their length can be calculated.

JavaScript
// Defining Lodash variable
const _ = require('lodash');

let val = "GeeksforGeeks";

// Checking for an ArrayLike
console.log("The Value is ArrayLike : "
    + _.isArrayLike(val)); 

Output:

The Value is ArrayLike : true

Example 3: In this example, the lodash _.isArrayLke() method returns false.

JavaScript
// Defining Lodash variable
const _ = require('lodash');

let val = { 1: 1 };

// Checking for an ArrayLike
console.log("The Value is ArrayLike : "
    + _.isArrayLike(val)); 

Output:

The Value is ArrayLike : false

Note: This will not work in normal JavaScript because it requires the lodash library to be installed and can be installed using npm install lodash.



RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4