JavaScript Array isArray() MethodThe 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. SyntaxParameterobj_value: It is the value of the object which is passed for determining whether it is an array or not. ReturnIt returns either false or true, depending on the test. JavaScript Array isArray() Method ExampleLet's see the below implementations and determine if the value is an array. Example1 This example shows a basic implementation of isArray() method. Test it NowOutput: ![]() It is clear that the passed values were not forming any array. Thus, the result is false. Example2 In this example, we will pass an array and check the resultant. Test it NowOutput: ![]() Hence, the output says that the passed value is an array. Example3 Let's check what if we pass 'null' as an object value. Test it NowOutput: ![]() Example4 Here is the code implementation where the object value is passed as 'undefined'. Test it NowOutput: ![]() Example5 Determining the object value and invoking the functions accordingly. Test it NowOutput: ![]() Function f1() is invoked because the value passed is an array. Example6 When we pass the object value as 'True'. Test it NowOutput: ![]() It shows that value is not in the form of an array.
Next TopicJavaScript 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