README.md (2371B)
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 # isArrayLikeObject 22 23 > Test if a value is an array-like object. 24 25 <section class="usage"> 26 27 ## Usage 28 29 ```javascript 30 var isArrayLikeObject = require( '@stdlib/assert/is-array-like-object' ); 31 ``` 32 33 #### isArrayLikeObject( value ) 34 35 Tests if a value is an [array-like][array-like] `object`. 36 37 <!-- eslint-disable object-curly-newline --> 38 39 ```javascript 40 var bool = isArrayLikeObject( [] ); 41 // returns true 42 43 bool = isArrayLikeObject( { 'length': 10 } ); 44 // returns true 45 ``` 46 47 If provided a `string`, the function returns `false`. 48 49 ```javascript 50 var bool = isArrayLikeObject( 'beep' ); 51 // returns false 52 ``` 53 54 </section> 55 56 <!-- /.usage --> 57 58 <section class="examples"> 59 60 ## Examples 61 62 <!-- eslint-disable object-curly-newline, object-curly-spacing, no-empty-function, no-restricted-syntax --> 63 64 <!-- eslint no-undef: "error" --> 65 66 ```javascript 67 var Float64Array = require( '@stdlib/array/float64' ); 68 var isArrayLikeObject = require( '@stdlib/assert/is-array-like-object' ); 69 70 var bool = isArrayLikeObject( { 'length': 10 } ); 71 // returns true 72 73 bool = isArrayLikeObject( [] ); 74 // returns true 75 76 bool = isArrayLikeObject( new Float64Array( 10 ) ); 77 // returns true 78 79 bool = (function test() { 80 return isArrayLikeObject( arguments ); 81 })(); 82 // returns true 83 84 bool = isArrayLikeObject( 'beep' ); 85 // returns false 86 87 bool = isArrayLikeObject( null ); 88 // returns false 89 90 bool = isArrayLikeObject( void 0 ); 91 // returns false 92 93 bool = isArrayLikeObject( 5 ); 94 // returns false 95 96 bool = isArrayLikeObject( true ); 97 // returns false 98 99 bool = isArrayLikeObject( {} ); 100 // returns false 101 102 bool = isArrayLikeObject( function noop() {} ); 103 // returns false 104 ``` 105 106 </section> 107 108 <!-- /.examples --> 109 110 <section class="links"> 111 112 [array-like]: http://www.2ality.com/2013/05/quirk-array-like-objects.html 113 114 </section> 115 116 <!-- /.links -->