hi everyone welcome to your 13
JavaScript basic video and wish your
gonna take a step back from all those
difficult aspects of scoping and stuff
and take a look at something known as
alert prompt confirm stuff like that in
JavaScript so so what happens is
basically these are not really
technically I should say a part of
JavaScript but are more of like a
utility function provided by the browser
itself the JavaScript by JavaScript what
I say it's not really a part of the
JavaScript engine which something you
can say which kind of powers your
JavaScript which interprets your
JavaScript so chrome uses we ate as its
engine so alert prompt alert prompt
confirm and basically these dialog boxes
are not really implementation of
JavaScript itself but browsers provide
those implementation let's really take a
quick look at what they are so I'm going
to say a load hello it saves you can see
when the script executes we get this
nice little hello alert from our web
page with just basically that's all
about right so just use this function
hello alert and pass in a message which
is a string or a number could be
anything
if you pass in an object it would kind
of not really display in a very nice way
you can see if I pass in an object okay
if I save this you see we get this
object object so things kind of break
down you can think of it right now I'm
gonna come to that later on why is it
like that but for now what happens is
that you can pass in numbers strings and
pretty much it'll work just like you
expect it to when you pass in objects or
anything else functions stuff like that
everything is valid in your script right
when you pass stuff like that it will
not really be very appealing right you
can see numbers also works fine the next
thing is basically conform conform is
kind of our dialogue box which you can
use to ask user if dish really want to
perform this particular action for
example deleting something relating a
photo or a contact or anything right so
you can say are you sure you want to
delete this it's safe
and you can see the browser renders it
like cancel and okay if I present okay
well what's the benefit of this well as
others as I told you that functions can
actually return values using the return
keyword so we can actually get the
result from this conform box and I can
console.log this result it's safe and
let's say if I said okay you can see we
get true here and obviously I want you
guys to put semicolons here right
okay we get true I press cancel we get
false
so now we can accordingly make decision
if result was true then we want to
perform this action otherwise well don't
perform this this cancel it on a similar
manner we have something more as prompt
which provides actually a text field for
the user to enter some text right cancel
we get null which is basically no value
as I told you the difference between
null and undefined for now you can think
of is basically null has to be
explicitly set to a variable so you know
that yes that variable does not really
have any value whereas undefined is
basically an unaged uninitialized
variable right which does not have any
value so if I change this to
what's your name
what is your name it's safe and I ain't
removal here hit enter you see we get
million console.log because that's what
we got back from the browser so this was
a quick video on alert front and confirm
people usually use alert usually used
confirm but I don't really think people
use a lot of prompt prompt is the
kind of used mostly in places where you
do not really want to focus on a lot of
you I just want things to go smoothly
and go fast basically all three of them
so yeah essentially it's good to know
about them in the beginning stages but
eventually you might not really need
them a lot of times so play around have
fun with these three load from them
conform dialog boxes and that's all for
this video I'll see you then in the next
one