README.md (2084B)
1 <!-- 2 3 @license Apache-2.0 4 5 Copyright (c) 2018 The Stdlib Authors. 6 7 Licensed under the Apache License, Version 2.0 (the "License"); 8 you may not use this file except in compliance with the License. 9 You may obtain a copy of the License at 10 11 http://www.apache.org/licenses/LICENSE-2.0 12 13 Unless required by applicable law or agreed to in writing, software 14 distributed under the License is distributed on an "AS IS" BASIS, 15 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 See the License for the specific language governing permissions and 17 limitations under the License. 18 19 --> 20 21 # isArrayLike 22 23 > Test if a value is array-like. 24 25 <section class="usage"> 26 27 ## Usage 28 29 ```javascript 30 var isArrayLike = require( '@stdlib/assert/is-array-like' ); 31 ``` 32 33 #### isArrayLike( value ) 34 35 Tests if a value is [array-like][array-like]. 36 37 <!-- eslint-disable object-curly-newline --> 38 39 ```javascript 40 var bool = isArrayLike( [] ); 41 // returns true 42 43 bool = isArrayLike( { 'length': 10 } ); 44 // returns true 45 ``` 46 47 If provided a `string`, the function returns `true`. 48 49 ```javascript 50 var bool = isArrayLike( 'beep' ); 51 // returns true 52 ``` 53 54 </section> 55 56 <!-- /.usage --> 57 58 <section class="examples"> 59 60 ## Examples 61 62 <!-- eslint-disable object-curly-newline, no-restricted-syntax, no-empty-function --> 63 64 <!-- eslint no-undef: "error" --> 65 66 ```javascript 67 var isArrayLike = require( '@stdlib/assert/is-array-like' ); 68 69 var bool = isArrayLike( { 'length': 10 } ); 70 // returns true 71 72 bool = isArrayLike( [] ); 73 // returns true 74 75 bool = isArrayLike( 'beep' ); 76 // returns true 77 78 bool = (function test() { 79 return isArrayLike( arguments ); 80 })(); 81 // returns true 82 83 bool = isArrayLike( null ); 84 // returns false 85 86 bool = isArrayLike( void 0 ); 87 // returns false 88 89 bool = isArrayLike( 5 ); 90 // returns false 91 92 bool = isArrayLike( true ); 93 // returns false 94 95 bool = isArrayLike( {} ); 96 // returns false 97 98 bool = isArrayLike( function noop() {} ); 99 // returns false 100 ``` 101 102 </section> 103 104 <!-- /.examples --> 105 106 <section class="links"> 107 108 [array-like]: http://www.2ality.com/2013/05/quirk-array-like-objects.html 109 110 </section> 111 112 <!-- /.links -->