text stringlengths 1 81 | start float64 0 10.1k | duration float64 0 24.9 |
|---|---|---|
used in the command line
stuff like, give me a DOM node | 4,967.63 | 3.6 |
or give me CSS on this DOM node,
stuff like that, that doesn't really | 4,971.23 | 5.01 |
make sense in a command line
interface, therefore those things | 4,976.24 | 5.43 |
are not on this global object. | 4,981.67 | 4.26 |
And then if we try to type
global, here in the window, | 4,985.93 | 6.03 |
that doesn't really make sense either. | 4,991.96 | 3.42 |
There's another thing that's
just kind of important to know | 4,995.38 | 2.67 |
but you might not ever
take advantage of it. | 4,998.05 | 3.589 |
But does that-- does that make sense? | 5,001.639 | 1.541 |
Cool. | 5,006.18 | 0.5 |
So let's move onto something that we'll
discuss a lot more in the next lecture | 5,009.62 | 4.18 |
but I'll go ahead and introduce
the concept in this lecture | 5,013.8 | 2.81 |
and leave you with a
little bit of a teaser. | 5,016.61 | 2.52 |
So who here has heard
of a closure before? | 5,019.13 | 1.86 |
So closures are actually
one of the things | 5,023.69 | 2.94 |
that JavaScript
programmers hate the most | 5,026.63 | 3.252 |
because it's a very, very
difficult concept to learn. | 5,029.882 | 2.208 |
Mostly because it's always
taught somewhat poorly. | 5,035.12 | 5.07 |
And so next time I'm going to try
to do a good job of teaching you, | 5,040.19 | 2.8 |
but I'm going to show you right now
the problem that a lot of people face. | 5,042.99 | 4.98 |
And so what closures are are functions-- | 5,047.97 | 2.74 |
is a behavior whereby functions
that refer to variables | 5,050.71 | 2.35 |
declared by a parent
function still exist, | 5,053.06 | 3.22 |
and it's possibly because of scoping. | 5,056.28 | 2.592 |
What the heck does that mean? | 5,058.872 | 1.208 |
I'll explain it in the next
lecture, but let's go ahead | 5,060.08 | 2.291 |
and explore what this actually means. | 5,062.371 | 4.537 |
All right. | 5,076.2 | 2.48 |
So let's do this. | 5,078.68 | 1.135 |
So first thing I'm
going to do is I'm going | 5,095.714 | 1.791 |
to declare an empty array
called array, and I'm | 5,097.505 | 2.889 |
going to fill that with a few values. | 5,100.394 | 1.541 |
That's And I'm using var intentionally. | 5,107.6 | 5.354 |
And that's push on a
function that does this. | 5,117.07 | 3.22 |
All right So what the
heck did I do here? | 5,143.85 | 2.38 |
So I declared a function
called makeFunctionArray, | 5,146.23 | 3.54 |
and all it does is it creates an
array, fill it with functions, | 5,149.77 | 3.33 |
and then invoke one of them. | 5,153.1 | 2.05 |
And so if I were to call this-- | 5,155.15 | 1.291 |
if I were to call this, I'd get back
an array full of functions, right? | 5,170.68 | 4.84 |
And what do we expect those
functions to do? each of them? | 5,175.52 | 3.054 |
Print a number, right? | 5,182.56 | 0.93 |
And so what should
happen is I should just-- | 5,183.49 | 3.122 |
I should be able to march through this
array, invoke each of those functions, | 5,186.612 | 3.208 |
and get back something
that counts, right? | 5,189.82 | 2.86 |
Basically? | 5,192.68 | 1.547 |
So let's see what happens. | 5,194.227 | 1.083 |
So I'm just going to access
that first one and invoke it, | 5,198.53 | 2.9 |
and we expect it to print out 0. | 5,201.43 | 2.41 |
So that there is one, a JavaScript
programmer's worst enemy, | 5,207.57 | 5.98 |
because it's somewhat unexpected,
and as we'll see in coming lectures, | 5,213.55 | 3.59 |
that is actually as expected. | 5,217.14 | 2.75 |
So I'll leave you guys on that
cliffhanger for next time, | 5,219.89 | 2.84 |
and we'll go ahead and
officially end lecture. | 5,222.73 | 2.6 |
I'll stick around if you any questions. | 5,225.33 | 3.27 |
[MUSIC PLAYING] | 0 | 4.419 |
BRIAN YU: All right,
welcome back everyone | 17.72 | 1.75 |
to Web Programming with
Python and JavaScript. | 19.47 | 2.28 |
So last time we took a look
at a brand new web framework | 21.75 | 2.88 |
written in Python called Django. | 24.63 | 2.01 |
And what Django allowed us to do was
to build dynamic web applications. | 26.64 | 3.63 |
Applications where we
now had the ability | 30.27 | 2.31 |
to not just display the same HTML and
CSS to the user every single time, | 32.58 | 3.96 |
but to dynamically
generate HTML in order | 36.54 | 2.37 |
to allow users to interact with a page
that was a little bit more dynamic. | 38.91 | 3.36 |
Doing things like rendering things on
the page only if a certain condition | 42.27 | 3.45 |
was true. | 45.72 | 0.78 |
Or looping over a list of values
and displaying one HTML element | 46.5 | 4.17 |
for each of those possible values. | 50.67 | 1.83 |
But where Django gets
especially powerful | 52.5 | 1.928 |
and we're web application
certainly get much more interesting | 54.428 | 2.542 |
is as we start to delve
into the world of data | 56.97 | 2.67 |
and trying to have web applications
that store data inside of a database. | 59.64 | 3.832 |
And to do that we're going to
introduce a couple of topics today. | 63.472 | 2.708 |
In particular, we're going to
introduce the idea of SQL, models, | 66.18 | 3.24 |
and migrations. | 69.42 | 1.17 |
SQL is a database language that we
can use to interact with databases | 70.59 | 4.05 |
and Django is going to allow us to have
an abstraction layer on top of SQL. | 74.64 | 4.35 |
To interact not by writing
direct SQL queries, | 78.99 | 2.64 |
but by interacting with
Python classes and objects | 81.63 | 2.85 |
that we're going to refer to as models. | 84.48 | 2.002 |
And migrations are going
to be a technique that | 86.482 | 1.958 |
are going to allow us to update
our database in response to changes | 88.44 | 3.81 |
that we make to our underlying models. | 92.25 | 2.74 |
So before we get into things
that are more Django specific, | 94.99 | 2.57 |
let's begin with a discussion
of SQL more generally. | 97.56 | 2.46 |
And more broadly, just a discussion
of data and the types of data | 100.02 | 3.03 |
that we're going to want to store. | 103.05 | 1.56 |
And now there are a number of ways
that we could try to store data inside | 104.61 | 3.3 |
of a computer system but
oftentimes in databases, | 107.91 | 2.82 |
in particular, in a type of database
known as a relational database, | 110.73 | 3.6 |
we're going to store data inside
of a table where each table is | 114.33 | 3.36 |
going to have rows and columns. | 117.69 | 2.35 |
So for the sake of today,
we're going to imagine | 120.04 | 2 |
starting to construct a
database and a web application | 122.04 | 2.73 |
that an airline might use. | 124.77 | 1.142 |
For example, for keeping track
of various different flights | 125.912 | 2.458 |
on that airline and keeping track of
which passengers are on those flights. | 128.37 | 4.14 |
And so what we have here is
a sample table, for example, | 132.51 | 3.15 |
of how you might represent a whole
bunch of flight related data. | 135.66 | 3.6 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.