Make $-prefixed properties of $firebaseObject non-enumerable
See original GitHub issuePresently, the $$conf
, $id
and $priority
properties of a $firebaseObject
are normal, enumerable properties. This is inconvenient if I want to loop over the object’s properties with a for .. in
loop or something like LoDash’s _.each()
method.
Currently I work around this with code like
_.each(someFirebaseObject, function (value, key) {
if (key.lastIndexOf('$', 0) === 0) {
// Filter out AngularFire methods on object
return;
}
else {
// do something
}
});
but this is ugly, and the ugliness is greater still in circumstances where what I’d really like to do is something like an _.map
call.
It would be more convenient if these properties were created with Object.defineProperty
to be non-enumerable.
Considerations:
- This will break IE 8 support (if the library isn’t broken in IE 8 already)
- … but you’re officially not supporting Angular 1.2.x any more, which was the last version of Angular to support IE 8, so you officially don’t support IE 8 anyway
- Concerns about IE 8 aside, this is technically a breaking change, albeit a minor one that probably won’t affect many people
- Angular are likewise considering making their
$foo
properties non-enumerable (see what is currently the final post at https://github.com/angular/angular.js/issues/6266) but may or may not follow through on this
I advocate making the change, but you may see things differently.
Issue Analytics
- State:
- Created 9 years ago
- Comments:16 (7 by maintainers)
Top Results From Across the Web
Enumerability and ownership of properties - JavaScript | MDN
Every property in JavaScript objects can be classified by three factors: Enumerable or non-enumerable;; String or symbol;; Own property or ...
Read more >What are the benefits of making properties non-enumerable?
I think the main benefit is to be able to control what shows up when enumerating an object's properties, such as for in...
Read more >Enumerability of properties • Deep JavaScript - Exploring JS
By making properties non-enumerable, we can hide them from some copying operations. Let us first examine two historical copying operations before moving on...
Read more >javascript object assignment
Create an object using Object.create (). For the most part object assign and spread work the same way, the key difference is that...
Read more >AngularJS 1.2.x - Plunker
Instead, one should create a $firebase object and call $asArray * on it: ... non-enumerable and non-configurable // and non-writable (its properties are ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@jamestalmage Thank you, this helped me as well.
Does @jamestalmage’s suggestion above of using
$firebaseUtils
not solve your problem? If so, please provide some more details.