question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Make $-prefixed properties of $firebaseObject non-enumerable

See original GitHub issue

Presently, 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:closed
  • Created 9 years ago
  • Comments:16 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
1dolinskicommented, Apr 2, 2016

@jamestalmage Thank you, this helped me as well.

0reactions
jwngrcommented, Aug 24, 2015

Does @jamestalmage’s suggestion above of using $firebaseUtils not solve your problem? If so, please provide some more details.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found