Discuss Scratch

MegaApuTurkUltra
Scratcher
1000+ posts

JavaScript Topic

TheAspiringHacker wrote:

It is a good thing!

  • () is the inhabitant of the unit type. The unit type corresponds with truth in the Curry-Howard Isomorphism. However, because Haskell features nontermination, all types are also inhabited by _|_. (This flaw also applies to Racket, FYI.)
  • Nothing is a constructor of Maybe, the option type. Instead of using null to represent absence of a value like in JS, you need to use Maybe, and thus must do case dianalysis/pattern matching, preventing null errors!
  • [] is the constructor of the empty linked list. You, as a Racketeer, should already be familiar with the definition of the linked list.

These “null” values are all of different types and have different meanings!

There's no need to be pendantic. Racket has #<void> (but nobody uses #<void> directly), maybe type implementations (there's no need to have it built into the language when it can simply be implemented by the programmer using core language features!) and ‘() too.
But of course, we just use ’() to mean null because it's simple, and aligns with the lisp definition of “null” (which, as you can guess based on lisp standing for “list processing”, would naturally be the empty list)
EPICPIKAGUY
Scratcher
100+ posts

JavaScript Topic

TheAspiringHacker wrote:

MegaApuTurkUltra wrote:

TheAspiringHacker wrote:

The check happens at compile-time! Therefore, y++ haskal > Racket!
non_sequitur.png

TheAspiringHacker wrote:

Also, I see that you are using '() as an equivalent of null! y++ haskal has (), Nothing, and [] for you to choose from based on the meaning!
And this is supposed to be a good thing? It's like JS undefined vs null vs empty array vs etc etc. Just confusing, and serves no useful purpose.
It is a good thing!

  • () is the inhabitant of the unit type. The unit type corresponds with the True proposition in the Curry-Howard Isomorphism. However, because Haskell features nontermination, all types are also inhabited by _|_. (This flaw also applies to Racket, FYI.)
  • Nothing is a constructor of Maybe, the option type. Instead of using null to represent absence of a value like in JS, you need to use Maybe, and thus must do case dianalysis/pattern matching, preventing null errors!
  • [] is the constructor of the empty linked list. You, as a Racketeer, should already be familiar with the definition of the linked list.

These “null” values are all of different types and have different meanings!


Professional JS programmer here.

You hear people complain all the time about how various comparisons with “null” and “undefined” are terrible and make no sense. And, sometimes they're right.

But most of the time, when you're writing code, you don't need to deal with that stuff. I do use “undefined” quite a bit, but it's fairly straight forward when you're comparing it the right way. Also, if you're trying to use numerical operations on things that aren't numbers (like 0 >= undefined), don't be surprised if you get strange results. But there are really detailed specs about the language, and any super-expert could immediately tell you why certain comparisons act in different ways.
MegaApuTurkUltra
Scratcher
1000+ posts

JavaScript Topic

EPICPIKAGUY wrote:

Professional JS programmer here.
professional
JS programmer
tbh, this is a “pick one” sort of situation. recent case in point
Jonathan50
Scratcher
1000+ posts

JavaScript Topic

I think this would be considered “BBCode testing”. If that's what you're trying to do, use the preview feature instead (the green check button.)
Endermuffine71
Scratcher
100+ posts

JavaScript Topic

Fun Fact: In the “about me” section if you write a line of JavaScript scratch detects it as a bad word. I believe this is Because of XSS.
But XSS dose not appear to function on Scratch anyways because i'm sure MIT know basic web page security.
If your not sure what XSS is it stands for Cross Site Scripting.
Another Fun Fact: Java and JavaScript are completely different Languages, and I love the Inspect Element Tool.
Also a Fun Fact: JavaScript is the Language used in web Development to communicate with a Server.(Basic JS knowledge.)
MOAR FUN FACTS: I love @Jonathan50 ‘s profile pic, its the Greek letter for l and used in Science as the symbol for wavelength

K thats all for now. I just thought I would post some Facts about JS and stuff. I don’t see much posts on the JS Topic and that makes me sad cuz I wish there were more programmers on Scratch that talked about other languages other than Scratchblocks, e.g Python, Ruby, Javascript etc…
Things like the JS board are cool because you see other code, and one of my fav examples of other languages on Scratch is there is a board on Scratch about C# blocks,(C# but in block format.) its really cool and creative. Edit: Here is the link to that if you want to check it out.

Last edited by Endermuffine71 (June 12, 2018 17:51:14)

Wetbikeboy2500
Scratcher
100+ posts

JavaScript Topic

Different ways to log a number random between 1 and 4
var b = Math.floor(Math.random() * 4) + 1.1;
    let a = b; //should always use let
    
    const c = a;//actually lets make it constant
    
    a = c; //I think that should work like this
    //level 1
    console.log(Math.ceil(a - 0.1));
    //level 2
    switch (a) { //this logs a number
        case 1.1:
            console.log(Math.ceil(1.1 - 0.1));
            break;
        case 2.1:
            console.log(Math.ceil(2.1 - 0.1));
            break;
        case 3.1:
            console.log(Math.ceil(3.1 - 0.1));
            break;
        case 4.1:
            console.log(Math.ceil(4.1 - 0.1))
            break;
    }
    //level 3
    console.log((a === 1.1) ? 1 : ((a === 2.1) ? () => {return Math.ceil(2.1 - 0.1);} : ((a === 3.1) ? () => {return Math.ceil(3.1 - 0.1)} : ((a === 4.1) ? () => {return Math.ceil(4.1 - 0.1)} : () => {return null;})))());
So pleasing to the brain.



Last edited by Wetbikeboy2500 (June 12, 2018 18:54:03)

ScratchDiogoh
Scratcher
1000+ posts

JavaScript Topic

Hello! I want to program JavaScript but not
Meeting Your Site
Wettining
Scratcher
500+ posts

JavaScript Topic

Endermuffine71 wrote:

Fun Fact: In the “about me” section if you write a line of JavaScript scratch detects it as a bad word. I believe this is Because of XSS.
But XSS dose not appear to function on Scratch anyways because i'm sure MIT know basic web page security.
If your not sure what XSS is it stands for Cross Site Scripting.
Nah there's been times when XSS was possible on Scratch but a few of us told them about these errors and they've patched them up; not everything is as secure as it seems
ScratchDiogoh
Scratcher
1000+ posts

JavaScript Topic

Bump
ScratchDiogoh
Scratcher
1000+ posts

JavaScript Topic

Bump

Powered by DjangoBB