time-to-botec

Benchmark sampling in different programming languages
Log | Files | Refs | README

README.md (1976B)


      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 # Object Keys
     22 
     23 > Return an array of an object's own and inherited enumerable property names.
     24 
     25 <section class="usage">
     26 
     27 ## Usage
     28 
     29 ```javascript
     30 var keysIn = require( '@stdlib/utils/keys-in' );
     31 ```
     32 
     33 #### keysIn( obj )
     34 
     35 Returns an `array` of an object's own and inherited enumerable property names.
     36 
     37 ```javascript
     38 function Foo() {
     39     this.a = 1;
     40     return this;
     41 }
     42 
     43 Foo.prototype.b = 2;
     44 
     45 var obj = new Foo();
     46 
     47 var keys = keysIn( obj );
     48 // e.g., returns [ 'a', 'b' ]
     49 ```
     50 
     51 </section>
     52 
     53 <!-- /.usage -->
     54 
     55 <section class="notes">
     56 
     57 ## Notes
     58 
     59 -   Name order is not guaranteed, as `object` key enumeration is not specified according to the [ECMAScript specification][ecma-262-for-in]. In practice, however, most engines use insertion order to sort an `object`'s keys, thus allowing for deterministic extraction.
     60 
     61 </section>
     62 
     63 <!-- /.notes -->
     64 
     65 <section class="examples">
     66 
     67 ## Examples
     68 
     69 <!-- eslint no-undef: "error" -->
     70 
     71 ```javascript
     72 var keysIn = require( '@stdlib/utils/keys-in' );
     73 
     74 function Foo() {
     75     this.beep = 'boop';
     76     this.a = {
     77         'b': 'c'
     78     };
     79     return this;
     80 }
     81 
     82 Foo.prototype.foo = [ 'bar' ];
     83 
     84 var obj = new Foo();
     85 var keys = keysIn( obj );
     86 
     87 console.log( keys );
     88 // e.g., => [ 'beep', 'a', 'foo' ]
     89 ```
     90 
     91 </section>
     92 
     93 <!-- /.examples -->
     94 
     95 <section class="links">
     96 
     97 [ecma-262-for-in]: http://www.ecma-international.org/ecma-262/5.1/#sec-12.6.4
     98 
     99 </section>
    100 
    101 <!-- /.links -->