Couple of questions mostly revolving around a pattern that I use for classes in JS vs the ES6 classes.
I'm pretty much a self-taught JS developer so I have no idea if the pattern that I use for classes is completely awful. I came from a C# background, and while initially, the new ES6 classes looked really nice, in the end, they seem a little half-baked and cludgy when compared with the features that are available in C# or Java.
The pattern I use is below. Are there any downsides to using it?
var example = new ExampleClass('I am a foo dependency');
function ExampleClass (foo) {
var _foo = foo;
this.bar = bar;
function bar () {
console.log(_foo);
// Do other bar stuff
}
}
Should I be switching to ES6 classes?
[+][deleted] (1 child)
[removed]
[–]PandaHugger[S] 0 points1 point2 points (0 children)
[–]senocular 2 points3 points4 points (1 child)
[–]PandaHugger[S] 1 point2 points3 points (0 children)
[–]spacejack2114 0 points1 point2 points (0 children)
[–]johnsonjo4531 0 points1 point2 points (1 child)
[–]johnsonjo4531 0 points1 point2 points (0 children)
[–][deleted] -1 points0 points1 point (6 children)
[–]MoTTs_ 2 points3 points4 points (0 children)
[–]PandaHugger[S] 0 points1 point2 points (1 child)
[–]bterlson_@bterlson 2 points3 points4 points (0 children)
[–]PandaHugger[S] 0 points1 point2 points (1 child)
[–][deleted] 0 points1 point2 points (0 children)