Discuss Scratch

ScratchDiogoh
Scratcher
1000+ posts

JavaScript Topic

Thanks to Scratch Team for being a Friend of this Topic
We can use the tag code js To Discuss JavaScript
<html>
var x = 200
<body class>
if <class>
var y = 899
deslike
hot var = 97
cold var old var
</html>
LuckyLucky7
Scratcher
1000+ posts

JavaScript Topic

list = ["ScratchCat"]
alert("Scratch Cat was here")
list.pop("ScratchCat")
Coding Error fixed.

Last edited by LuckyLucky7 (May 24, 2018 11:15:42)

ACE009
Scratcher
100+ posts

JavaScript Topic

LuckyLucky7 wrote:

list = ["ScratchCat"]
alert("Scratch Cat was here")
pop.list("ScratchCat")
I learned JavaScript before but I kind of don't remember everything about it.
Uh, you got pop and list backwards in the third line, it's list.pop() (since pop is a method of list, not list is a method of pop).
LuckyLucky7
Scratcher
1000+ posts

JavaScript Topic

ACE009 wrote:

LuckyLucky7 wrote:

list = ["ScratchCat"]
alert("Scratch Cat was here")
pop.list("ScratchCat")
I learned JavaScript before but I kind of don't remember everything about it.
Uh, you got pop and list backwards in the third line, it's list.pop() (since pop is a method of list, not list is a method of pop).
Ok

Last edited by LuckyLucky7 (May 24, 2018 11:14:49)

NickyNouse
Scratcher
1000+ posts

JavaScript Topic

ACE009 wrote:

LuckyLucky7 wrote:

list = ["ScratchCat"]
alert("Scratch Cat was here")
pop.list("ScratchCat")
I learned JavaScript before but I kind of don't remember everything about it.
Uh, you got pop and list backwards in the third line, it's list.pop() (since pop is a method of list, not list is a method of pop).
This code should make the above code work correctly:
(function() {
  window.pop = window;
  let _list = [];
  Object.defineProperty(pop, 'list', {
    get: () => {
      return item => {
        let index = _list.indexOf(item);
        if(index > -1) {
          _list.splice(index, 1);
          return item;
        } else {
          throw new ReferenceError(`"${item}" is not in pop.list`);
        }
      }
    },
    set: newList => {
      if(Array.isArray(newList)) {
        _list = newList;
      } else {
        _list.push(newList);
      }
    }
  });
})();
ScratchDiogoh
Scratcher
1000+ posts

JavaScript Topic

NickyNouse wrote:

ACE009 wrote:

LuckyLucky7 wrote:

list = ["ScratchCat"]
alert("Scratch Cat was here")
pop.list("ScratchCat")
I learned JavaScript before but I kind of don't remember everything about it.
Uh, you got pop and list backwards in the third line, it's list.pop() (since pop is a method of list, not list is a method of pop).
This code should make the above code work correctly:
(function() {
  window.pop = window;
  let _list = [];
  Object.defineProperty(pop, 'list', {
    get: () => {
      return item => {
        let index = _list.indexOf(item);
        if(index > -1) {
          _list.splice(index, 1);
          return item;
        } else {
          throw new ReferenceError(`"${item}" is not in pop.list`);
        }
      }
    },
    set: newList => {
      if(Array.isArray(newList)) {
        _list = newList;
      } else {
        _list.push(newList);
      }
    }
  });
})();
Let's continue!
When Scratch is var
(function(2.000.000)
move 75 steps
if <Scratch> else <Scratch*>
6n´´``
pi 

NickyNouse
Scratcher
1000+ posts

JavaScript Topic

ScratchDiogoh wrote:

Let's continue!
When Scratch is var
(function(2.000.000)
move 75 steps
if <Scratch> else <Scratch*>
6n´´``
pi 

I… don't think anything I do will make that not be a syntax error
ScratchDiogoh
Scratcher
1000+ posts

JavaScript Topic

NickyNouse wrote:

ScratchDiogoh wrote:

Let's continue!
When Scratch is var
(function(2.000.000)
move 75 steps
if <Scratch> else <Scratch*>
6n´´``
pi 

I… don't think anything I do will make that not be a syntax error
Errors of synthesis are for example: ´´, /…
ninjagolloyd
Scratcher
500+ posts

JavaScript Topic

ScratchDiogoh wrote:

NickyNouse wrote:

ScratchDiogoh wrote:

Let's continue!
When Scratch is var
(function(2.000.000)
move 75 steps
if <Scratch> else <Scratch*>
6n´´``
pi 

I… don't think anything I do will make that not be a syntax error
Errors of synthesis are for example: ´´, /…
…do you know what javascript is?
TheAspiringHacker
Scratcher
100+ posts

JavaScript Topic

var pooh ===== tigger;
oof(oww; my) {
    bones;; xdd
}
std::System.out.console.cout << "Bone hurting juice" <<<<< std::flush;
(putStrLn "Ouchie") >> (putStrLn $ show pooh)
Like my JS? :^)


/sarcasm

Last edited by TheAspiringHacker (May 29, 2018 23:04:06)

ScratchDiogoh
Scratcher
1000+ posts

JavaScript Topic

TheApiringHacker wrote:

var pooh ===== tigger;
oof(oww; my) {
    bones;; xdd
}
std::System.out.console.cout << "Bone hurting juice" <<<<< std::flush;
(putStrLn "Ouchie") >> (putStrLn $ show pooh)
Like my JS? :^)
/sarcasm
You did not put JS! Was it to fool us?
dude341
Scratcher
1000+ posts

JavaScript Topic

ScratchDiogoh wrote:

You did not put JS! Was it to fool us?
Yes, this is why they said “sarcasm”

Last edited by dude341 (May 30, 2018 20:48:41)

ScratchDiogoh
Scratcher
1000+ posts

JavaScript Topic

dude341 wrote:

ScratchDiogoh wrote:

You did not put JS! Was it to fool us?
Yes, this is why they said “sarcasm”
What's?
dude341
Scratcher
1000+ posts

JavaScript Topic

ScratchDiogoh wrote:

dude341 wrote:

ScratchDiogoh wrote:

You did not put JS! Was it to fool us?
Yes, this is why they said “sarcasm”
What's?
Sarcasm basically means a joke.
ScratchDiogoh
Scratcher
1000+ posts

JavaScript Topic

dude341 wrote:

ScratchDiogoh wrote:

dude341 wrote:

ScratchDiogoh wrote:

You did not put JS! Was it to fool us?
Yes, this is why they said “sarcasm”
What's?
Sarcasm basically means a joke.
I have not seen!
TheAspiringHacker
Scratcher
100+ posts

JavaScript Topic

dude341 wrote:

ScratchDiogoh wrote:

You did not put JS! Was it to fool us?
Yes, this is why they said “sarcasm”
Maybe ScratchDiogoh meant that I chose Haskell, not JS, as the syntax highlighting?
MegaApuTurkUltra
Scratcher
1000+ posts

JavaScript Topic

JS tends to be weird
0 <= null
true
0 >= null
true
0 == null
false
0 === null
false

I prefer racket
(<= 0 '())
; <=: contract violation
;   expected: real?
;   given: '()
;   argument position: 2nd
TheAspiringHacker
Scratcher
100+ posts

JavaScript Topic

MegaApuTurkUltra wrote:

JS tends to be weird
0 <= null
true
0 >= null
true
0 == null
false
0 === null
false

I prefer racket
(<= 0 '())
; <=: contract violation
;   expected: real?
;   given: '()
;   argument position: 2nd
I prefer y++ haskal:

Prelude> 0 <= ()

<interactive>:1:1: error:
• No instance for (Num ()) arising from the literal ‘0’
• In the first argument of ‘(<=)’, namely ‘0’
In the expression: 0 <= ()
In an equation for ‘it’: it = 0 <= ()
The check happens at compile-time! Therefore, y++ haskal > Racket!

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!

Last edited by TheAspiringHacker (May 31, 2018 03:01:26)

MegaApuTurkUltra
Scratcher
1000+ posts

JavaScript Topic

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.

Last edited by MegaApuTurkUltra (May 31, 2018 03:03:38)

TheAspiringHacker
Scratcher
100+ posts

JavaScript Topic

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!

Last edited by TheAspiringHacker (May 31, 2018 03:23:26)

Powered by DjangoBB