Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Jan 31 22:17
    CrossEye commented #2779
  • Jan 31 21:04
    ArturAralin commented #2779
  • Jan 31 20:08
    CrossEye commented #2779
  • Jan 31 18:56
    buzzdecafe commented #2631
  • Jan 31 18:09
    ArturAralin commented #2779
  • Jan 31 16:18
    CrossEye commented #2779
  • Jan 31 16:10
    CrossEye commented #2631
  • Jan 31 16:06
    CrossEye commented #2777
  • Jan 31 14:44
    ArturAralin opened #2779
  • Jan 31 07:39
    inferusvv commented #2631
  • Jan 31 03:07
    sespinozj commented #2771
  • Jan 31 02:33
    machad0 commented #2771
  • Jan 31 02:26
    JeffreyChan commented #2777
  • Jan 30 14:30
    CrossEye closed #2777
  • Jan 30 12:13
    vanyadymousky updated the wiki
  • Jan 30 01:42
    JeffreyChan commented #2777
  • Jan 29 21:06
    vanyadymousky updated the wiki
  • Jan 29 16:28
    CrossEye commented #2777
  • Jan 29 15:50
    mbostock commented #2772
  • Jan 29 15:48
    CrossEye commented #2772
Brad Compton (he/him)
@Bradcomp
It is most definitely an OO language, and a Functional Language, and an Imperative language, etc. It has been multi-paradigm since the beginning.
But think about how common it is, and has been for years, to pass in callback functions
Long Dao
@longebane
then why is JS always parroted as an OOP lang?
Brad Compton (he/him)
@Bradcomp
I'd say it's one of the main things people need to learn when moving over to JS from less functionally capable languages
Because it is one, but that doesn't mean it's not functional too
Long Dao
@longebane
I agree. But the argument is that it is OOP first, with functionality for other styles
and here Ian comes and says it was a FP language first
Ian Hofmann-Hicks
@evilsoft
Well I would not say first, because it was general purpose when it was released to all of us
Long Dao
@longebane
ok, then I misunderstood you
Ian Hofmann-Hicks
@evilsoft
more that it was built on the foundation of a functional language
with the other stuff tacked in in the 11th hour
Brad Compton (he/him)
@Bradcomp
Both paradigms are built into the core of the language
It's a pretty weird OO language in a lot of ways too though
Long Dao
@longebane
then would it be safe to say, it was built on the foundation of a funtional language, and then appended by OO-heavy devs to be more OO?
Ian Hofmann-Hicks
@evilsoft
I just do not use the OO bits because of my aversion to state
Brad Compton (he/him)
@Bradcomp
Most languages don't use prototypical inheritance
The scoping is weird and it didn't get classes till 2015-ish?
Long Dao
@longebane
but isn't prototypical inheritance still a subset of OO
Brad Compton (he/him)
@Bradcomp
Then you have stuff like calland apply
It is, but if it was inspired by Java it certainly had a ... unique take
Ian Hofmann-Hicks
@evilsoft
Yes, but not the norm @longebane. what some would call Traditional OO
Brad Compton (he/him)
@Bradcomp
You can use prototypes similar to classes, but they can also be used for some rad metaprogramming, multiple inheritance, mixins, etc.
Long Dao
@longebane
Ok, then instead of "JS is an OO language", what would be better?
that's essentially what I'm getting at
Brad Compton (he/him)
@Bradcomp
JS is a multi-paradigm language supporting OO, Functional, and Imperative programming styles, as well as allowing the user to mix and match
Long Dao
@longebane
deja vu. I feel like I've seen that before
Ian Hofmann-Hicks
@evilsoft
:+1: to that @Bradcomp
Long Dao
@longebane
looks great!
Ian Hofmann-Hicks
@evilsoft
:sheep: :it:
Long Dao
@longebane
:red_circle: :eyes:
Brad Compton (he/him)
@Bradcomp
Because of this, it can support a wide variety of applications and use cases. It also provides a number of footguns for users that await the incautious developer.
Long Dao
@longebane
footgun?
Brad Compton (he/him)
@Bradcomp
It will pretty much let you do anything and won't try to stop you
Long Dao
@longebane
traps?
Brad Compton (he/him)
@Bradcomp
Leading to a number of ways to shoot yourself in the foot
self sabotage
:stuck_out_tongue_closed_eyes:
Long Dao
@longebane
yeah. good stuff. thanks my brah's
Ian Hofmann-Hicks
@evilsoft
Anytime! Is your course going to be public?
Carl Parrish
@carl-parrish

I have an object {} my object may have several nested properties.
const myObj = {prop1: {prop2: {prop3: data: null}}}
I need to set data if it's empty

 if ( R.isNil(myObj.prop1.prop2.prop3.data))
  {
     myObj.prop1.prop2.prop3.data = myCurrentDataObj ;
 }

This works as long a prop1, prop2 & prop3 exists. But sometimes they don't so I tried

If (R.isNil(myObj.prop1)){ myObj.pro1 = {prop2: {prop3: data: {}}}; }

Do I actually have to explicitly check to see if every property has been defined before I can set data? I was hoping that something like R.lensProp and R.set could solve this for me but if so I haven't figured it out yet.

Brad Compton (he/him)
@Bradcomp
Look at R.pathSatisfies
and other similar functions
Carl Parrish
@carl-parrish
thanks
Brad Compton (he/him)
@Bradcomp
const dataPath =  ['prop1', 'prop2', 'prop3', 'data'];
when (
  pathSatisfies(isNil, dataPath),
  assocPath(dataPath, {})
)(myObj);
assocPath will create intermediate properties I am pretty sure
Carl Parrish
@carl-parrish
will try that now.
Brad Compton (he/him)
@Bradcomp
also change out the {} with myCurrentDataObj
and it won't update your input, but instead create a new object based on the old one
Carl Parrish
@carl-parrish
but only if it was nil right?
Brad Compton (he/him)
@Bradcomp
If pathSatisfies returns false (the property isn't nil) then it will just return myObj unchanged