Skip to main content

almost 6 years ago Syntax Podcast

Hasty Treat - Stump'd

Wes Bos

Wes Bos Host

Scott Tolinski

Scott Tolinski Host

Topic 0 09:18

What is a stateless component in React

Wes Bos

and returns the same output

Scott Tolinski

and, it's a function without a hook.

Scott Tolinski

Okay. This is a good one to go along with this. I don't think this one's particularly difficult even though it's listed as hard,

Wes Bos

anything else. So given that it's it's a pure function. Right? Given that it takes in data, it always returns

Wes Bos

it's a function that takes in props HTML and React event handling? And I I went into the answer just to get a little bit more, e, f, g, and then a 3rd person comes along and and ask for a, b, c again, it can go, oh, I already have that. I I memoized it. I remember it. And you can, like, store that in, like, a map or an object or something like that. You are just dancing around on this work. You're it's like it's like the word What's the word? JS on the floor, and you're just, like, leaping over every single time it's directly in front of you. Caching.

Wes Bos

100% of the time, guaranteed, Stumped.

Scott Tolinski

a dog without a collar. It's, you know,

Scott Tolinski

A component that does not have state. In the past, a stateless functional component would have just been on the function component, but now with hooks, they have a state. So a stateless component is literally just a component that has no state, This is an intermediate one, but this doesn't seem this seems like an easy one.

Wes Bos

the exact same thing. Yeah. I'm gonna give you that. Correct. There's no side effects.

Scott Tolinski

It's a

Topic 1 07:01

What states a promise can be in

Scott Tolinski

any gotchas with this.

Scott Tolinski

So

Scott Tolinski

I'm trying to think if there's, like, any,

Scott Tolinski

The discuss the differences between an

Scott Tolinski

resolved,

Scott Tolinski

fine. Okay. We have an intermediate question for Wes, and this is in the topic of HTML.

Wes Bos

The resolved, rejected, initialized? I don't know the the language here. Yeah. Is that it? I'll give it to you. Yeah. So that's it's it's pending, which it says initial Scott. So that's initialized.

Scott Tolinski

I don't know, it's like a if you throw, does that just that just rejects it? Yep.

Scott Tolinski

can be, So what is they're looking for the differences between local storage and it's a mason jar without some cold brew in it.

Scott Tolinski

rejected,

Topic 2 05:55

What are the JavaScript data types

Wes Bos

Alright. Next question

Wes Bos

undefined, without parentheses.

Scott Tolinski

JavaScript

Wes Bos

In which states can a promise be? When the tab is closed, I'm gonna say. So when the tab is closed, not when the browser is closed. No. When when no. When the entire browser is closed. Like, when you quit the you quit the browser, and

Wes Bos

Oh, okay. Alright. This is I always like doing this Node, and I always screw it up.

Scott Tolinski

What is a data type? Because it doesn't say what are the.

Scott Tolinski

data types?

Scott Tolinski

Not like what are they, but, like, what are like, what is a data type? Okay.

Wes Bos

Number, string,

Scott Tolinski

null You have 2 more. Symbol

Wes Bos

Although sorry. Like, is it asking what the what the types are in JavaScript? The

Scott Tolinski

What are Obviously,

Wes Bos

Boolean.

Wes Bos

for Scott.

Wes Bos

I've I've asked you that on the podcast, and you rattled them off. No problem. I had to really think about that.

Topic 3 00:00

Transcript

Scott Tolinski

and try it out today. You're gonna get 14 days for free with that LogRocket

Scott Tolinski

URL. So check it out.

Scott Tolinski

as it happens. So that means you can scroll scrub through the video. You can get your network request as they happen. You can get the console log as it happens, the Redux store, or any of those cool things that you have never seen from an error and exception handling tool. This is not just like some bread crumbs to try to find the problem. This is literally how the problem happened, giving you

Wes Bos

Fahrenheit, which

Wes Bos

I'm doing okay.

Wes Bos

38 degrees here, which is They

Announcer

Bos, and Scott, el toro Loco,

Announcer

Monday. Monday. Monday.

Scott Tolinski

hasty treat, we're gonna be playing a game of Stumped. Now this is a game that we probably haven't played in, like, a year or so maybe. It was a game that Wes and I made up

Announcer

Tolinski.

Scott Tolinski

and you're going to be blown away by some of the cool stuff it does. Basically, it gives you a session replay of a bug error exception happening

Wes Bos

It's, like,

Scott Tolinski

syntax,

Scott Tolinski

Node if you've never used LogRocket, you wanna check it out at logrocket.comforward/ My name is Scott.

Wes Bos

a 100.4 and the other person has to attempt to answer it. Wes will make fools of ourselves. Fools.

Wes Bos

Yeah. So Incorrect. The first one It is true, false. Is true. So I didn't well It it JS true, false. Can I get bonus points for, at least guessing that that would be the the final downfall? Yeah. You shoulda you shoulda answered it that way.

Announcer

soft skill, web development, the hastiest, the craziest, the tastiest web development

Announcer

Open wide dev fans. Get ready to stuff your face with JavaScript, CSS, Node modules, barbecue tips, get workflows, breakdancing,

Scott Tolinski

Welcome to Syntax. In this Monday,

Scott Tolinski

unprecedented access to solve this problem. So check it out at logrecorddot it just says what are JavaScript data types, but it looks like it's looking for what 7 data types are.

Wes Bos

Americans get much hotter, I know, but it's hot for a Canadian here. I'm used to snow.

Announcer

treats coming in hot. Here is Wes, barracuda,

Scott Tolinski

Stumped.

Scott Tolinski

comforward/syntax

Scott Tolinski

So my name is Scott Tolinski. I'm a developer from Denver, Colorado, and with me as always is the Wes Balas. How are you doing, Wes?

Scott Tolinski

Yeah. Yeah. It's been in the hundreds up here too. Well, up here down here. I'm I'm way far down compared to you, but yeah. So this episode's sponsor is LogRocket.

Wes Bos

on a popular podcast. So, let's go I forgot about it. Somebody somebody, like, said, hey. You should do a stump. And I was like, oh, yeah. I forgot about doing stump. Oh, yeah. That exists. Yeah. Yeah. We should do that.

Topic 4 13:09

What is memoization

Wes Bos

the values,

Wes Bos

the inconsistencies Malicious. Get us.

Wes Bos

where a function which mean that it goes outside of the function regardless of

Wes Bos

product a, b, c, and then someone does another fetch request for product does some sort of does not have any

Scott Tolinski

man, a lot of these hard ones, they just don't feel hard enough for you, Wes. I'm trying to stump you, and I know you're not gonna get stumped by this. So here's Node. What is memoization? to try to stump each other with Internet questions. Yeah. It's been a long time. It has been a long time. It's been too long. Been too long since I've been embarrassed on a,

Wes Bos

so that when it runs the 2nd time, it doesn't have to recompute those values. Yeah. What's a good word for that that, That was not as hard. Not as

Wes Bos

But that this is I think the reason you got that wrong is because you probably don't use double equals, and so you don't even know what the standards body and the people from the browsers have, in React? So you have, like, a click handler, and you wanna pass an argument to a method.

Wes Bos

you have, like, a like, a fetch request. And if somebody does a fetch request for on the attribute

Scott Tolinski

of using double equals because you just don't use it. Use it ever. Yeah. Yep. Yep. Yep. Yep. This is a good one. Although,

Wes Bos

remembers

Wes Bos

Alright. Next question for mister Tolinski.

Scott Tolinski

but they they really wanted to hear that word caching, and I you know, Wes, I just did New York. But, no, you you got it. You got it right. So

Scott Tolinski

Caching. Yes. But, yes, you are you are on point. Yeah. Your answer described it fine,

Scott Tolinski

Something that's good good for me me to hear to make sure you understand this concept.

Scott Tolinski

I would like to it's in the good to hear sections.

Wes Bos

A React question.

Topic 5 07:51

Differences between HTML spec and browser implementation

Scott Tolinski

Oh,

Wes Bos

So the the spec is just Wes are using this 30 seconds of interviews .org, which has a whole bunch of, like, like, little okay. But but it no. That's not true in HTML elements. Like, if you put a handle click parenthesis I didn't know that. What book did Stojan Stefanov? in HTML, it's not gonna run until the the event handles. Oh, no. No. I know. I'm saying like That is correct.

Wes Bos

HTML specification I'll I'll give you that. I I think the one of the keys there, if you're getting this interview question, is,

Wes Bos

actually how they've implemented it. And those are supposed to line up, but sometimes they don't, and there's cross browser

Wes Bos

Because you know this weird thing.

Wes Bos

Is that good?

Wes Bos

difference between and inline event handlers in React JSX?

Scott Tolinski

and a browser's implementation thereof? Mhmm. I think you I think this one might be easier than you're,

Scott Tolinski

No. That was I thought that was gonna be, like, much harder. I guess this does have some things that say, like, define the rules that must adhere to an owner, be valid according to the specification.

Wes Bos

It's like a lot of words to basically say the same thing. Come on. That's a silly question. It's a silly question. Come on. Who who's who's asking that in a interview? You know? Like, oh, do you really know HTML? but you just have to tell me what the output of it is. So you've got 3 variables, a, b, and c.

Wes Bos

Oh, this is a easy React question. What is a stateless component? little, like,

Wes Bos

come together and propose and very much like the CSS that we have, and it's all been approved as to how it should work. And then the browser implementation

Scott Tolinski

Yes. I think that's perfect. Wes don't know. I mean I mean, there's the body and then how how it's the spec and then how it's implemented. I don't know. It's not really too deep of a Yeah. Yeah.

Scott Tolinski

and a browser's implementation thereof.

Scott Tolinski

putting in your brain.

Topic 6 10:10

What is a pure function

Wes Bos

The first variable a is is an array where the items are 1, 2, 3. The 2nd

Wes Bos

side effects,

Scott Tolinski

but it's a good good one to go along with the the last one we just did. And what is a pure function? that will love my friend when clicked.

Wes Bos

to update stuff or to fetch data or anything like that. It it simply just depends on what's handed to it and always returns the same thing. Yep. Always returns the same thing. That's it. Nailed it. So this is an intermediate one. It's gonna be a bit a little bit of mouth coating, inconsistencies.

Wes Bos

So you've got an array of 123, another array of 123, and then the 3rd string of 1 comma 2 comma 3. Got it? Got it. Now the question is here.

Wes Bos

of 1, comma, 2, comma, 3.

Wes Bos

There's there's it's a 2 parter.

Wes Bos

the exact same output. And that that function

Wes Bos

b is also an array. Same Node. Items are 1, 2, 3. So so far, you have 2 variables. Both of them are their own arrays with 1, 2, and 3 items in it. And then you have, object,

Wes Bos

Oh, there you go. A pure function is a function that, given its inputs, will, a 100% of the time, always return Yeah. We need some, like, expert level, like, intentionally double quotes

Topic 7 03:31

Difference between HTML and React event handling

Wes Bos

React camel cases its event handlers.

Wes Bos

that's okay because, like like, how often do you write in, like, event handlers on a on, like, a button. Right? Very probably never. Never. No. Before that, I used jQuery.

Wes Bos

they they mean what is the difference between, or or you could also use single quotes as well. And then, also, React, you pass it reference to the function to an event handler is

Wes Bos

So you on click, on submit, things like that. What's the different Node a couple differences between the 2?

Wes Bos

clarity on this. But,

Scott Tolinski

Yeah. I think that's true of any function, though, not just a ESLint event handler,

Scott Tolinski

Yeah. Otherwise, it runs in the JSX.

Wes Bos

So,

Scott Tolinski

oh.

Wes Bos

One difference is that, wasn't that Eloquent?

Wes Bos

There you go.

Scott Tolinski

their own event system that, like, mirrors the Dom one. Is that correct?

Wes Bos

So it would be on click with a capital c in React. And on HTML, it's all lowercase.

Wes Bos

And in HTML, you actually

Scott Tolinski

No matter what what what you put a function on anything, it's going to run. That's true. Regardless in React. Yeah. Okay. So,

Scott Tolinski

Aren't they not the same? Like, aren't the the React ones just their own thing, synthetic events that are, like, Yeah. Let me let me keep going here because,

Wes Bos

It's not that's not on here, but you're right about that. But that's that's not what it says here. There there are some actual Woah. Woah. Woah. Woah. Woah. Physical on,

Scott Tolinski

I'm sorry. What I what I meant is that React.

Wes Bos

inside the quotes, you put the parentheses on the end. That's a a sort of a gotcha that that people have.

Wes Bos

I'm gonna get I'm gonna give you a fail on that. And

Wes Bos

in a in a attribute It's like, fulfilled, which is resolved,

Wes Bos

The other difference is that, HTML uses

Scott Tolinski

that's big big f for me. Wes, I'm gonna get you Node here. Popping it open.

Scott Tolinski

Yeah.

Wes Bos

inline event handlers on a button,

Topic 8 15:15

How to pass argument to event handler in React

Wes Bos

How do you pass an argument Eloquent Java c variable c, where it is a string

Scott Tolinski

arrow functions to just simply call because

Scott Tolinski

You have to. Just kinda comes back to the Yeah. Fact. So if you just have Earlier, we talked about. If you just have parens at the end of your function, it runs. So you've Scott, there's several ways you you can the way that I'm doing it is I'm writing an inline arrow function

Scott Tolinski

inline anonymous HTML specification

Wes Bos

Beautiful. Do you know another way that is very not so popular anymore? Find.

Topic 9 15:54

Explain local storage vs session storage

Scott Tolinski

myself into that. It's not the first time you second guessed yourself today, Scott. I trusted my heart twice, and my heart has led me astray.

Scott Tolinski

yeah. When the tab is closed you're very close.

Scott Tolinski

Explain local storage

Wes Bos

I'm gonna guess that the difference between local storage and session stories, they're both key value stores.

Wes Bos

However, local storage will stay with the browser, I've looked this up once. I've never used session storage. I remember, like, finding it in the dev tools. I was like, oh, what's that?

Wes Bos

Eloquent? heavy process of of doing some math or even, like, I've done it in the past where

Scott Tolinski

and session storage.

Scott Tolinski

session storage. Oh,

Scott Tolinski

JavaScript design patterns. That was his book. You know what? It's funny. When I I was saying that, I I was like,

Scott Tolinski

something like that. You're smiling. Let's say you have a Chrome rendering bug preventing you from looking at the screen. No. The answer is

Scott Tolinski

he says what? I feel like we need some more, like, real hard ones. Yeah. We need to find a new pool because just about all of these, I was like, he ain't gonna answer this. I've heard him talk about this before. So

Wes Bos

JavaScript's good part. Yeah. The good part. No. Eloquent JavaScript is Martin Haverbeck.

Wes Bos

Alright. Let's wrap it up here. Thanks so much for tuning in, and we'll catch you on Wednesday.

Scott Tolinski

Well Wes, yeah. Crockford did,

Scott Tolinski

You're just about there, but I'm I'm gonna need some clarification on when exactly a session storage,

Wes Bos

you reboot your computer, I, Oh, that's

Scott Tolinski

Yeah. So in in Douglas Crockford's,

Wes Bos

Peace.

Scott Tolinski

JavaScript, the good parts Wes coming out of my mouth, and I was like, no. Wait. That's not JavaScript, the good part. It's all good. I was like, well, yeah, I corrected

Scott Tolinski

actually do this again. That'd be fun. Yeah.

Wes Bos

And that's probably also handy. I wonder if you have 2 different tabs of a website open We should oh, cool. Well, I learned something. I got stumped, though.

Scott Tolinski

what did he do? What states can a promise be? It can be

Wes Bos

but session storage will be cleared For whoever wins gets to ask the 1st question,

Scott Tolinski

is cleared. Is it when the browser is closed? 30 seconds of interviews Scott or .org.

Wes Bos

like, a on, like, a restart of the browser or something like that.

Scott Tolinski

Not when the browser JS closed, although that will do it. It's just not the the, you know, the main one. No. No. But, like, if you if you close the browser you go close the website and go back, that session storage will be will no longer be there? Just when the just when the tab itself is closed.

Scott Tolinski

you know, JavaScript, he or or eloquent JavaScript on page thirty four, it's

Wes Bos

Stumped. Alright. Is that it? That's it. Alright. That was fun. We should we should do that again. Yeah. We should do this. It was maybe we should,

Wes Bos

malicious questions.

Wes Bos

if that would be separate session storage. That's a great question. Very well maybe. I bet. I bet.

Scott Tolinski

Because I nailed it. Yeah. I got a hard HTML question for you, and that is what is HTML 5 web storage? Wes,

Topic 10 11:40

Compare equality of array and string

Wes Bos

What is the output of

Wes Bos

and double equals only performs a check on the values and not the Yeah. So, like, maybe we should give an example for people listening. If you've got like a, I just wanna hear a word. There's a specific word I'm looking for. It's a word. Like, if you have, like, a function that, and rejected, which is rejected. Nailed it. I'll give you a 10 out of 10. Cool. Even though I got the words wrong, it's cool. I'm I'm into it. That's

Wes Bos

2 arrays, even though the values are the same, it doesn't do a deep check. It just checks for reference of objects. Yeah.

Wes Bos

Is that your final answer? I

Scott Tolinski

So,

Wes Bos

there you go. Double equals. The type. So it converts the array to a string before it before it compares. Man, Double equals. It'll get you. The second1 is false because,

Wes Bos

a equals equals c, You trusted my partner. Why. It was double equals,

Wes Bos

and what is the output of a equals equals b? So do you want me to, Node. I got it. I think they're both false. I think they're both false.

Scott Tolinski

the the way that this is all presented is lining up for the the first one to be true and the 2nd one to be false for some reason. But I'm gonna go with false false because that's what my heart's telling me.

Scott Tolinski

I would I would think that they are both false just offhand in my brain space when I try to visualize this.

Scott Tolinski

you know, I don't.

Scott Tolinski

They warn you That's good. When you're learning double equals, that'll get you. And you might just be on a podcast doing a game show, and that's when it gets you. I gotcha.

Wes Bos

Alright.

Topic 11 03:03

Wes wins rock paper scissors to ask first question

Scott Tolinski

My brain skills are are really firing on all cylinders today as you can tell. Alright. My question here is the intermediate one. It says, what is the difference between

Scott Tolinski

I win. I papered his rock. It's so hard with the latency. Wes we what happens is we each end up going slower each consecutive time because we're both trying to account for the latency.

Wes Bos

So, that's it. Do you want a rock, paper, scissors?

Topic 12 02:27

Wes and Scott play game 'Stumped' to quiz each other on web dev questions

Wes Bos

quick little gotcha questions. And not necessarily gotcha questions, but just interesting things, and they vary from easy all the way up to hard.

Topic 13 02:43

Categories for questions: HTML, CSS, JavaScript, React, Node, Sanity

Wes Bos

And we just wrote a little snippet that we paste into the console that will randomly grab 1 of the 300 questions

Wes Bos

on here,

Wes Bos

are what what are the categories? HTML, CSS, JavaScript, React, Node, and Sanity.

Share

Empowering developers for over 286197063116 milliseconds!