Great good afternoon. Everyone.
Well, actually, good evening. Let's be. Let's be accurate.
So. Thank you all for those select few who have decided on this evening is currently Monday evening, September 26.th As you can see.
Actually, yeah, you can see that it's 8 36 Pmacs buffer that's being shared currently.
So.
This lecture.
That would happen.
Time at a workshop.
You can't see the entire window.
What?
You really kits.
Okay. Why can't you see? Okay, let's figure out what's going here. Let's.
Okay, so window, system, window.
At the end of, okay, let's try. Okay.
How about now?
Is that better? No.
Why, okay, let's.
I think part of the reason why is, I've got some.
Okay, let's.
Put that over there.
This. This is so irritating.
Okay? Because if this doesn't work, I'm gonna have to do something else different. So.
Okay. Stop. Sharing. Okay.
So now it shouldn't be anything sharing correct.
Yeah. Okay. Good.
And now let's.
That's good. That's reporting.
And.
Where are my share? Controls.
Give me my share, controls.
My window has to be that wide.
And.
Let's do this.
Poor!
Share.
Share screen.
How about now? It looks like the whole windows. There, now.
Are we good?
Okay.
I have no idea why it just was, because it's.
You know his evening so.
Gonna have some some silly. So what I was saying is, so I'm at a workshop. I'm actually.
I'm I have. Student of mine is presenting a paper here. So I'm here for this. I've also been involved this workshop for a long time, so.
Hopefully. It's just something for this week. But.
So we're we're in a different time.
So.
So before we get well, I would kind of talk about some.
Some things of working with your Vm.
So right now, for some reason, my Vm.
Is not so accessible right now, and I'm don't have time to debug it.
But I can show you what I wanted to show otherwise. So.
So Deno and other places may work the same. When we get into later stuff, it may get kind of weird. So it's good to get into a habit of doing this.
And so the tutorials that's where we're gonna support.
But as part of that.
So Via's code is a great tool for doing.
Remote editing of files.
So if you want to bring up a file.
In the cloud, and edit it directly.
You can do that.
So is not the only solution. There's many other systems that can do this. So.
You don't. Even if you're working with cloud resident things. Once you have Ssh up, there's no reason that has to constrain how you use it.
And that's why I really encourage you to use the class vms for you to.
Learn how to use these tricks.
So here I want to demonstrate one of things like I was gonna do this with the class vm, that I have set up. But for some reason.
But I'll show you with something else.
So.
If you look at this you'll notice that this is actually the Directory for.
The Web fund. You know the web fundamentals 24 run. This is.
The files on my web. Server.
I have a local copy of these files.
But that's not where this is.
This is.
On my class. Not class. Vm, on my vm, that's the wiki server.
And you can tell this because it says Ssh. At homeost Ssh homeostasis.
Home Soma publication. Also that whole bit means that emacs.
Using Ssh to connect to remote things. So I can actually do things like.
I can follow the things here. I can look at those I can bring up.
The notes. There's a notes file here.
And it's loading it notes a little slower because it's having to load it over the network as transfer it in order to edit it, but if I like make any changes, it will save directly to the server.
It doesn't have to do anything in between. So here, I'm gonna kill this.
Like all these other things, I could probably even watch the video in here. I'm not gonna try doing that because.
I'm on Hotel Wi-fi, and it's just gonna be bad. But.
This is just to show you, and also, like all my code for class here. This is all there.
So.
Just because you're using the cloud.
Does not mean you can't use your local tools.
So Vs code locally will.
Interact with cloud stuff. Emacs will do it. Other editors and things will do this.
And a lot of them will support remote debugging and stuff we're gonna get. See how much deep we may get into debuggers later on. But.
For right now, the basic environment I'm gonna use.
Is mostly
Okay.
Oh, oh, this is really funny!
I submit, I said Max Shell, and it's automatically assuming I want to do a remote.
And after a second.
Do, do.
It, loaded.
Funny, prompt, and everything that's kind of weird.
But it's.
It's correct.
Anyway. Well, we don't know about that.
So what I'm going to do instead is.
So we're do here. We're going to go to.
This is on my local machine.
And we're going to go here.
Wanted to kill this buffer.
And we're going to switch over.
Yeah, we're gonna kill this.
Let me keep this here. So now we're back.
Just doing. So. I'm gonna keep things local because I want to run.
Demo here, so I'm running demo here. The assets.
Local. I'm sorry, but.
I'll try to do things more remotely in future lectures.
So what I want to do today.
Go through Javascript. Just talk about some basics.
And
And also point out like. So if you go to the class, Wiki.
And you go to
2.
Yes, STA.
So we'll go here. We'll go to.
Actually, I have the page right here. That's why this is here.
And then we're on a main page. And so if you go here.
And you look at the course outline.
Oh, I don't! Oh, so I don't have the text here. I thought I put here. No, it's not here.
It is here at the bottom.
Of the page. So you'll notice there's a resources thing here on learning Javascript.
So there's a great book here, eloquent Javascript.
Full book, online.
There's some more in depth things. No, Javascript yet. There's Javascript. That's a book you might want to buy. That's a.
You'll probably have to buy it.
There's an online access which you have to pay for. These other 2 are free.
What I'm pointing out is, there's lots of books on Javascript.
I highly recommend you. Spend some time.
Just reading through it. So like, if you go to eloquent Javascript.
Here's a nice book here. It's got a.
You know, introductions, value types, program structure, functions, data objects, higher functions.
Gives me all these things.
This is worth just sitting there and reading through. It's not that long.
I say this because I'm gonna talk about Javascript as a language. Certain key features.
But I'm gonna go through it rather quickly, and my focus is more going to.
On the code that we're doing in
In class, and that we need for doing web applications.
So it's not a full view. It's not certainly full power of it. Javascript is a very powerful language.
And at this point you've already learned.
2 Other Programming Languages.
You know you learn Java. You learn python.
Javascript got a few weirdnesses, and I will be talking about the weirdnesses.
But
Yeah, go ahead and and read it, and you should be able to.
A computer scientist should never be afraid of another programming language. I mean keeping them straight. They all do things. But once, as you learn programming language. You realize.
Oh, that was just like this one. But it's just a little different here like that. And so.
I'm gonna focus on the ideas that are in Javascript.
That are in
But then they're in other languages. But.
Okay, so there we go.
So let's let's talk.
So just to.
Kind of get that out there.
Now let's go to.
Where's my term?
So this right now I'm running.
Deno is in a red print loop.
What that means is, I can type in code.
And it will
Return
Values. I really should probably.
Run this in reverse video with all the way highlights are set.
Anyway.
Door.
No, that's not an option.
I was looking to see if those in a command I could run just to reverse video, because it's an option. When you start. B. Max, there's another way to do it. But I'm not gonna fill with that. During lecture.
Back to room, so.
What can you do to redevelop, print, loop.
So what the idea is that you type in some code.
It evaluates it.
And it returns. The result of that evaluation.
This is not something you do in a language like Java.
Because Java is compiled.
So a language.
The.
To.
So you generally have a print loop in interpreted languages.
But not in this. Now I'm putting interpreted here in quotes, because.
There's this thing be called just in time compilation that makes.
That's actually how the things running fast. But when I say interpret, I mean is.
You type in something, it interprets it and prints the result.
So if I type 2 plus 2, oh.
God! Is it really gonna be like that?
Okay, let's.
This is going to be very painful unless I change this.
I'm sorry I'm going to have to stop this. Let's stop that.
Stop sharing.
Quit emacs.
And remember to do this.
Hopefully. I've not messed this up.
Okay. Can you see Max again.
Reverse, video.
Great perfect thanks.
There!
That's probably more appropriate for a nighttime class.
There that works better.
So.
Oh, you can never remember the key bindings in Vimac.
Well in them.
How things work is kind of set in emac.
You can customize them.
You can customize them to be whatever you want. In fact, in my emacs I have changed several commands.
To be function keys.
To prevent me from doing weird control key sequences.
So
Yeah, don't let that be a barrier. You can change them to be whatever you want.
And there's a handy, dandy menu.
For doing these things, which actually has a lot of the.
Default bindings.
Yeah vim. You can, too. But vim is designed as a modal editor.
Emacs is modless, which means it kind of like works. Like most modern Gui programs, vim is like, you're an editing mode, or you know,
Insert mode or things.
So it's so. There's the keys. But there's also the weird conceptual thing.
Emacs can actually imitate them.
It has this thing called Elvis mode, which makes it behave like them.
But
Yeah, emacs' entire operating system.
So anyway.
So I'm doing 2 plus 2.
Redevelop print loop. I type in an expression.
I entered it, it evaluated it, it printed it out.
Why do I like redevelop print loops.
Because they let.
Play with the language and go like. Is that what it is.
Is that how it works? You can do experiments.
Because that's the real secret of learning how to work with
Computers is you.
You have to form hypotheses.
And then try things out and see what happens.
And sometimes you're gonna get.
You know, you know it'll surprise you, and sometimes it won't. And you know this is how you build up your mental model.
Because that's what you need is a good mental model of how these systems work.
You know, redevelop print makes that much easier than opposed to typing in poiling it, seeing what happened, and stuff.
And I want to show you why this comes so that.
There's a couple of weirdnesses.
About Javascript that you should know.
So kind of like python.
You don't have to declare variables before using them.
Although you really should.
And I'll show you some ways of doing that in a bit. But now, so I can type.
If I type X here.
So here by default. It says, X. Is not defined in older versions of Javascript.
This would just say,
It would just say X's, you know.
It would just say something else. I'll show you what it will say. But I could say, varx.
So you notice here, I type X.
And then I typed X.
So let's 1st do the second one. So the 1st one is, I declared X to be a variable.
Right, and then I.
I just typed X to see what the value of X is.
Notice the value of X's undefined.
So this is the 1st thing we are like.
Variables are names for vow. Variables are names.
And the names are associated with values which could be anything. It could be an array. It could be a.
Function. It could be a number. It could be like anything but.
The name doesn't have a type. The value it has.
The value can is referring to as a type.
So you have a name. It could refer to anything.
Now there's a extensions to Javascript, like typescript, which have types associated with it. But even in things like typescript.
Types are
Optional. You might go. Wait.
Isn't that weird? Well, if you're doing Java.
Yes, not having a typ is gets kind of weird. But if you're used to, python seems kind of normal.
The other weird thing, though.
Is so here. I declared it. I said, Vrx. I didn't say varx, and I didn't say it was an integer or anything. I just said it.
Also. The semicol, I think, is technically optional, although I think newer versions of Javascript may try to enforce you on that end. So the statement ending. Javascript's a little flexible on this.
But then the value of X is undefined. It did not give an error.
Variables in Javascript, when you just declare them.
They're they have a value assigned to them.
Undefined, undefined, is a value.
In Javascript. And in fact, it's also.
So.
It's a good question, why not 0? We'll talk about that. There is a very distinct reason for that.
Notice that when I typed in Varx somebody called it returned the value undefined.
So let's see if I say var.
Y equaled 2.
I'm doing this to show you. Now we have this Y value, and if I type YI get 2.
But why did I get undefined there? See, it's not when the var expression.
It's not.
It's not returning the value of the variable. It's just there's nothing to return, because it just did something.
So if there's an expression that has no explicit value to return.
It will return a value in Javascript. It's just always going to be undefined.
So why not 0.
So when you have a variable, and you have undefined.
You know it's undefined.
So now let's so. Let's look here. Now, let's do x.
Plus y.
Not a number.
Why is it not a number.
Because X is undefined.
It's not going to be undefined, but it's going to say not a number. I could say if XI could now say, X equals.
4. I think it's the x plus y.
And we get as we expect.
Now, if I say XZ.
It's gonna go! Whoa! You didn't declare it.
But if I say Varsity.
I say x plus z.
Says, not a number x.
Is a number Z.
Is undefined. So this.
So this is this design. Feature of Javascript is.
It's a little questionable.
It. It just is.
No other language that's commonly used is quite even python.
It'll like a language like Python will generate a runtime.
So.
So that's that's really the problem is like.
No no sign, sorry.
Runtime sorry problems.
Yeah. So let me clarify that it could be a.
Runtime error. It's gonna jump through an exception.
And you clearly, Javascript, has we just saw it. Uncut. Reference, error.
That's you know, right there.
Or you know, or could. If there was a compile thing, you can compile it and see the error. But no, Javascript doesn't do either of these things, it just happily uses the value.
And goes on.
Now you could say.
So when would this be a feature.
Any thoughts on when this would be a feature.
You know.
Nick.
So, just.
This is us. This is the thing of Javascript. It's probably one of the things that everyone hates about Javascript.
Because just give me an error.
Didn't want you to try. Oh, so here's a fun thing.
So we can say.
Oops!
Okay, so a is that B is that a plus B.
Yep, a plus.
Space.
Plus B. Hello there.
Nothing too weird about that right?
That was XYZ.
A plus z.
Do you see that.
It turned undefined into a string.
And concatenated it.
Twitch twitch. This is part of why people hate Javascript.
This is, I can excuse this.
This is just.
This is like, there's a lot of tools to help minimize this.
There are linters. There are other things, but it's there in the language. And remember what I said about the problems of the web, never changing cuts and evolve system. We're stuck with us.
Yes, it is an oh no.
So.
Beware!
It gets even more fun.
It gets more fun.
So let's say so. A is the thing so I can. I can now set a equal. I've already designed a as a variable.
Say, 1, 2.
3, 4, 5.
So that's a very all right. So a is a nice thing, so I can say a of.
2.
It's 0 subscripts a 0.
Is that a 1 is that.
A 4 is 5.
And what's af.
Fine.
And oh, here it's even better.
I can say a a of 4 equals.
22. So I say, hey, that's all. Good.
I can say a of 5.
Equals, 23.
That's all good. What if I say a of 10.
Equals, 50.
Hmm, hmm.
So a of 9.
They have 8.
Hope, that.
So you can extend, arrays.
By just assigning past them.
But note that.
Yep, so like, so.
Javascripts.
They start at 0 sparse, you can assign to them.
I was about to put quotes around undefined. But I didn't want to put quotes around undefined, because that implies that undefined as a string, and it's not. It's the value. But of course, if you treat it as a string it would become a string.
Can, undefined be considered as no.
Not quite. It's much weirder again. You saw that whole thing with the string.
With undefined like it. You know this.
This thing there, you wouldn't see this sort of behavior.
With if under if
With a value like no.
A via like Null would generate.
Exceptions.
Undefined, doesn't generate a setions.
A flexible no, and that is the hallmark of Javascript Javascript.
Traditional Javascript. Does it throw exceptions.
It just muddles along and tries to keep the computation going.
Changes to Javascript.
Tried to make it more, that when things get weird it just generates.
But the old stuff Haver has to be kept because Javascript is in use so much and break code so.
So kind of a flexible? No, but I mean.
That when you're programming Javascript, you have to keep this in the back of your mind.
That.
What if you wanted to shrink an array.
There is a way to shrink arrays
I'd have to look it up.
So so another thing to
To keep in mind about Javascript.
But.
Dot test. Dot. Js files. Oh, yeah. So in Javascript.
In web development. You often have lots of.
Testing files for testing things. And this is part of the reason why you have yet to be aggressive about testing Javascript code.
Is because you don't have the compile. Time checks. You would another language.
And so, yeah, very aggressive unit and functional tests is.
There! But
So another talk about is Javascript's a kind of a functional language.
So this is another big thing. And so I just want to tell that there's there's lots of stuff about Javascript.
And we'll go through things as as a semester goes on as needed.
Go read the book I'm now just trying to give a highlight of some.
Key points. So one big thing is this whole undefined thing which is just.
Nuts. When there is this dynamic nature that I can kind of do these things.
The other big thing is
Functions, and how they work, and that ties closely.
To Javascript's notion of.
Objects.
So what am I saying here.
So I can say.
So I can say, function.
So I say, I say a.
Oh, sorry. Yeah. So I said, Foo.
Who was a function.
I say? Who of 2.
It returns 7.
Does this all seem pretty straightforward? How I'm defining Foo. If you have questions I can do that.
But I can also do.
So notice this. See, I can define a function.
And this is called an anonymous function here, because it has no name.
I can define this function, I can assign it to a variable.
I can then take that variable, and assign it to another variable.
And that all works.
Perfectly fine.
Now you might go.
Why define functions.
Why do that now?
Now there are.
So there are languages.
Where you really can define and manipulate functions as data types and do all kinds of.
Funny things to. Those are true functional languages.
Like if you're talking about things like Haskell, lisp.
Can also do, although it's kind of a little more macro base and stuff. There's some languages that really can.
Slice and dice code like that.
You don't do that. I think Javascript can kind of do that through some mechanisms. That's.
Not normally how things are done.
But being able to define functions on the fly.
Turns out to be very important.
Because
Because of scope.
This is a question for you. Have you ever heard the term lexicaling.
Hmm! Is that a term that any of you come across.
It's related to local versus global.
But it's a fancier thing.
So I'm going to. Let's go to
Let's say scope, genus.
So let's do a little scoping.
So when I say this, I'm going to make a function.
Outer.
So this is functions gonna take value. A.
And we're going to define it here. And we're gonna do this.
This is a function, a.
They function out.
And then I do.
I want you to gaze upon this code for a second.
Just look at it.
This should look a little weird.
What's happening here.
Is we have a function outer.
Inside of function. Outer. There's another function called inner.
And what we do when we rock, call outer.
All we do is return. The value of.
We don't do anything else.
And then, if we call inner.
We return a plus b.
But note where A was defined. A was B is defined here.
A is defined here.
So.
What does this look like in practice.
So I'm just going to go here and take this code. I could load it in, but I can just paste it in.
And.
Here.
Okay. Let's see.
Okay, this is annoying.
Okay, this is very annoying. How do I do a paste into my terminal because it's emulating the terminal a little too well.
Okay. So I'm doing help on this terminal here. So term mode.
Okay, terminal input size.
Route to apples can cause windows scroll in the buffer space process, and this can be customized.
Role, map, send raw.
Okay.
That can't be right.
Sorry I might. So so what I'm doing right here this is a little curiosity, is you can at any mode.
An emacs. You can look up the Help command for it. So I'm just kinda curious how to do what it is, because I don't know how to do pasting inside this thing.
I'm just gonna forget this.
Let's go to Denho.
This is a different demo. This is using a different mode that show.
Scope.
This should work. I can do this.
Powder.
Function in there.
Undefined.
So if I type
Bar.
For a equals.
That's good. You've got a good question about what it does like an object, or I'll explain that in a second.
So we've got a is out, you know, out of here. Now we say a of.
2.
So notice what happens. Here.
A and B.
Both refer to the function inner.
Shouldn't it give the same value.
Yes, except.
The value of a.
Comes from this outer scope.
So when we, when this returns, it returns this function inner, but it returns it with the value of a.
Bound to when this was returned, and so that now preserves state.
So this is called lexical scoping.
Because.
The variable that you see is the one that is.
Based on.
The text. So you could do this dynamically.
Where, the value of a.
Like I could define a i i could say
Notice. The A and B here are completely different from these, A's and B's here.
Because these A's and B's are inside the function. This one is the top level.
This is not inside of this, so this can't be seen here. There's no.
There's no confusion between these A's and B's. They're completely separate.
So in some sense lexical is just kind of keeping things like if people have name variables and other things elsewhere, it doesn't matter. It's what can I see?
In the text of my code. That's what symbols I can see like here. I'm going like, what a is that? Referring to it, I go out, go out! It must be that a.
And this B was referring to. Oh, it's right there. It's just you start the line of code, and you start going out or outer to the outer scopes.
Till you get to the top level, which is outside of any function you go like. That's what the.
Definition of the value is, and if you go out there and there's nothing to find for it. There.
That. That's when you know that it's.
Undefined.
So you could think of. There's actually this thing. It's an environment model.
Whether these different environments.
For holding this, but.
What it really is.
Here's the funny thing is.
It's kind of an object.
Is it a relative version of local versus global.
Kind of yeah, instead of local and global. In Javascript, what you have, there is a global scope.
The global scope is like this top level one. That's where I'm putting things in here.
And then, but whenever you define a function, it defines its own scope.
And here's the funny thing that scope is actually an object.
Which is really kind of a dictionary.
It's a bunch of key value things, an associative map.
So associated with every function.
Source.
So.
This all this stuff. I'm gonna leave a little squishy because going into the exact semantics of it gets a little messy. But.
You know, it's there's this weird equivalence between objects and scopes.
And dictionaries.
In Javascript, and.
There are actually some subtle differences between them, and as you learn the language in more advanced way, you'll kind of see how it all fits together.
I don't think we're gonna get that deep.
In here, but to a 1st approximation. You can see this now, when I say, what do I mean? There's.
This! Well.
I can also define.
I can say far.
Wish I do. We'll call this.
No, it's not like an object. I'm trying to think what's a good.
What's a good dictionary.
Yeah, I'm just gonna do this. So.
For
So just like you have array defined by this, you know, you know a b comma c.
All in Javascript. You can also define with curly braces.
And so you say, like a.
One b.
To.
C. Call 3.
Because I didn't put a trailing semicolon because Javascript doesn't mostly care.
I tend to put them in, but.
You don't have to. So I can say table.
So that's kind of an associative array.
And so you can assign values to it.
Would I say that function.
There's there's a test.
So you notice, this is a dictionary.
What does Javascript say? It is.
What's the type of table.
It's an object.
Javascript concerned? Why? Why?
Why?
Why huh?
Why is this called.
An object.
Because think about it.
If you want to define an object, what do you need.
Need to have. Look. You need to have.
Values. And you need to have methods.
Because Javascript is so flexible with values and other things.
I can make this be.
I can make table.
D.
Pull, 2.
So is this the same thing as objects in Java? No, not really.
So object as a concept of computer science.
Is
So it's, what is an object? Really? An object is a data type.
What's associated with that data type.
What are they called? Object?
Have you talked much about inheritance?
As the thing with objects.
So this is the kind of notion of.
The dictionaries are objects that function as object that has scope in an attribute. So functions. You'll notice it's kind of opaque.
As an object in older Javascript runtimes would be a little more things to be option stuff. Now, that doesn't show you the structure of it, because now Javascript does lots of funky things with it.
I'll get to. I'll get to that in a bit. First.st Talk about.
Inheritance with that composition was the thing to use.
Yes, you are correct.
So I'm saying, this is what we used to talk about. This is what we used to teach.
Few decades ago.
So specifically, what we would say is, you'd have, like a class animal and a subclass of animal.
Is bird. And so if you have a parakeet, the parakeet, you know, is it'd be a bird object, which is also an animal object, because bird and hair this is called is a heritage, because.
Is, it is an animal, a bird? No. Is a bird an animal? Yes, because.
There's this hierarchy of things that you know.
From one to the other.
So like. If you change the base class.
Then
You know you could do that. So.
So what does this mean is when we want to make a bird, we have an animal object.
In, you know, inside of it.
And that's all we do.
So here's another weird thing.
So Javascript style of objects is called prototype-based.
Objects rather than class. So you could think, you know, when you have a class.
You have an abstract notion of a class, and then you create. You know.
So that's what. Yeah. With a prototype-based inheritance, your prototype is concrete.
Has used as a template for making objects.
I could spend a lot of time talking about this.
I'm kind of tempted. But this is not a programming language course. I just want to teach you enough, Javascript, to be dangerous.
So
I'm just saying all this stuff. Just so. You don't try to treat Javascript.
Like Java.
The reason. Javascript.
Javascript and Java both look like similar to each other syntactically, because they're both descendants of. They both.
Look kind of like. See? Java was really hot when Javascript was created, and so they wanted people to associate with, so they call Javascript. This is a move by netscape, and naming it.
There's nothing. There's no connection between these languages.
At all. They're completely different. Beast.
So don't get confused by the name similarity. It's a very stupid historical artifact.
So why, I mention all this, you're not gonna find.
Big class declarations in Javascript.
You're not going to find type definitions in Javascript.
You're going to find lots of weird things like undefined behavior. You're gonna.
Find a dynamically growing dictionary, associating objects and.
Dictionaries and stuff like.
There's all this stuff that's just not there in Java.
Is it? Good or bad? I mean, it's different.
It! It's.
Simpler.
It allows you to. I mean, Javascript is really at its heart.
It's base things, aren't. It's really easy just to get code together. And just.
Get it running.
You don't have to think about things. If when you scale Javascript up, it tends to.
Problems
Yeah, it. It tends to have problems. So there's there's an issue of scale.
So.
Along these lines.
That's it. Let's go back to the tutorial code, and let's look at what is it doing here?
But.
Okay, I'll stick around after this ends. I can take questions after I end lecture.
So sorry to write this to.
Let's run to my desktop, so it's here. So I don't. Max overwrite the master copy.
So.
What do we have here?
We declare some variables.
You know, comes arguments.
Note. Deno is an object.
It's an object, one of the elements of the you know, one of the.
Properties of that object.
Is Args, which is an array. We're accessing the elements of that array.
Note how deno is
Yeah. Yeah. But like, if you look in the thing like, there's no prototype for dental. Just.
An object.
And what are the map, you know, also has lots of.
Methods associated with it.
You know, like this.
Now.
You see all this stuff here, you see how this is a method and stuff like this. All looks well and good.
I'm gonna show you something.
Disturbing. Let's see if it lets me. I think it will let me do this.
Oh, it didn't let me do that!
I was curious if Demo was gonna try doing that. So.
And older versions of Javascript.
So I could do like console.
Log.
That's a function.
Oh, it didn't let me do it!
Yeah, see what I just did to myself.
Consoles and object.
Consoles and object. It has a whole bunch of functions.
Including one called log.
But it's not a function anymore, because I assigned to the object.
I gave it a value, and now.
I broke it, and now.
It's I can't call console log right now.
In there, so.
Demo. I can't seem to do that, Demo.
Like. Here's the object. Here's all the things in the demo object. You can kind of see all the cool stuff in here.
But I tried assigning to it.
And it didn't let me change. So I think Deno is a protected object. It won't let me.
Mess with it so much, but.
Other core Javascript stuff you can. Is this common? Yes, this is core to how Javascript works.
Like when you start looking at code like this.
You see that you're accessing.
Objects.
So you might go like.
You know. Lines. Oh, okay, there's another question. Here is.
Why is, how did I do lines? I index.
That's a method of that.
That's because.
Lines up. I is a string.
Strings have methods. One of the methods of string is index of.
Now, is it? Yeah. So is it common to break objects? It's actually fundamental to the language.
That it lets you do this for most objects. There's a few things like.
Makes sense, because it's not a standard part of Javascript. They decide to protect it. But things like the console object.
Or other things that are core. You can redefine them. And in fact, some people like when they're doing their code. It depends on redefining it because they make console, do different things.
Like. They say, I don't want console to actually write things to the console. I want to do something else, or I may want it to save a copy of it before I do that.
And so they'll change how the core.
Objects of Javascript work. The methods are what's the value of things, and it will change the functionality. So it's a very.
I mean, it's very malleable.
Which allows it to be very flexible.
But if you don't know what you're doing like, you're sitting here playing around like some of your code decided to.
You know, I type in, you know.
And I was doing some funny things. And so, my code, I happened to use the same variable and make another console object that mirrored that shadowed the console object, or I changed methods of it and replaced it and stuff you're in a world of hurt.
So in other languages you'd have things like.
Oh, that symbol's already been defined, or that's a reserved words, and you can't mess with that. Javascript's not like that.
It'll just let you do it.
And oh! And even the funnier thing is some.
Some of the security of Javascript systems actually require you to be able to mess with this, because what they do is they redefine some of these core symbols.
To prevent new code from accessing these methods. And that's a way of.
Sandboxing Javascript, limiting what it can do, because, like, oh, you can't. If I get rid of console log, you can't write to the console anymore. And that's not a bug. That's a feature.
So
Does this mean importing and exporting code very difficult? I'm not really.
It just means that you have to be careful that if you.
So remember the whole scoping thing like most of the time. This stuff doesn't.
You can do the stuff at a local scope, and it's fine. But if you mess with a global scope.
We have these special objects that come with the runtime, you start changing them.
Yeah, you can break your entire Javascript. But of course it's just the current runtime you restart Javascript. It's gonna be all different. And you know it'll be clean.
So, but yeah.
You gotta watch out for that.
Anyway. It's late. I have a couple of minutes left. I'll stick around to answer questions. I think.
Gotten to a good stopping point. Unless there's any last minute questions, I'll stop lecture here.
And
I'll have to make up a lecture quiz before I go to bed. But
Otherwise
Thank you all for the few who attended tonight.
And the rest of you hope this lecture was.
Semi-coherent.
And I will.
Probably on Thursday, but there will be a Thursday.
So stop sharing.
And.
I'll just say Thank you very much.
Now and recording, now.