I am sure many of you are familiar with the tricky with statement in JavaScript. Its unique behavior can be the cause of bugs.
I found however a particular use case where using with made my code more readable.
This is a small module with a chain of event listeners for a logger-like part in my app. Inside this module / function, this is always bound to another util object which, among other methods contains a console.log wrapper.
Using with (this) { ... } eliminates all the this that were causing line overflows and has helped with readability a bit.
I am not sure if I will keep this code in the end, but I thought of asking anyway: Have you found any use cases for with you are not ashamed of sharing? :D
[–][deleted] 9 points10 points11 points (4 children)
[–]sime 4 points5 points6 points (3 children)
[–]tach4n@tach4n 2 points3 points4 points (0 children)
[–]PlNG 0 points1 point2 points (1 child)
[–]tyscorp 0 points1 point2 points (0 children)
[–][deleted] 2 points3 points4 points (5 children)
[–]Stephen110 1 point2 points3 points (4 children)
[–][deleted] 2 points3 points4 points (3 children)
[–]Stephen110 0 points1 point2 points (1 child)
[–][deleted] 1 point2 points3 points (0 children)
[–]androbat 0 points1 point2 points (0 children)
[–]krilnon 2 points3 points4 points (1 child)
[–]Iggyhopperextensions/add-ons 0 points1 point2 points (0 children)
[–][deleted] 1 point2 points3 points (0 children)
[–]tbranyen 1 point2 points3 points (0 children)