The isArray() method is used to test whether the value passed is an array. If it finds the passed value is an array, it returns True. Otherwise, it returns False.
obj_value: It is the value of the object which is passed for determining whether it is an array or not.
It returns either false or true, depending on the test.
Let's see the below implementations and determine if the value is an array.
This example shows a basic implementation of isArray() method.Test it Now
It is clear that the passed values were not forming any array. Thus, the result is false.
In this example, we will pass an array and check the resultant.Test it Now
Hence, the output says that the passed value is an array.
Let's check what if we pass 'null' as an object value.Test it Now
Here is the code implementation where the object value is passed as 'undefined'.Test it Now
Determining the object value and invoking the functions accordingly.Test it Now
Function f1() is invoked because the value passed is an array.
When we pass the object value as 'True'.Test it Now
It shows that value is not in the form of an array.
JavaTpoint offers too many high quality services. Mail us on h[email protected], to get more information about given services.
JavaTpoint offers college campus training on Core Java, Advance Java, .Net, Android, Hadoop, PHP, Web Technology and Python. Please mail your requirement at [email protected].
Duration: 1 week to 2 week