Null vs Undefined – Beau teaches JavaScript [w/ subs]



00:00:00 – no verse undefined these are both
00:00:02 – datatypes in java script and JavaScript
00:00:05 – undefined means that means a variable
00:00:06 – has been declared but has not yet been
00:00:08 – assigned a value such as as you can see
00:00:14 – when i run this in the console it shows
00:00:16 – that the variable test is undefined i
00:00:19 – have created the variable but i haven't
00:00:20 – set it equal to anything but if I am
00:00:23 – here if I say that test people know and
00:00:29 – then I canceled that log it you'll see
00:00:36 – that it shows not on the console know is
00:00:39 – an assignment value it can be assigned
00:00:41 – to a variable as a representation of no
00:00:43 – value
00:00:44 – so while undefined set automatically
00:00:47 – just by not assigning a value javascript
00:00:49 – never sets a value to know this must be
00:00:51 – done specifically in your program so
00:00:53 – let's test some things about null and
00:00:55 – undefined we can see the type of know it
00:01:00 – is an object this is actually for legacy
00:01:03 – reasons that it doesn't show a type of
00:01:04 – not but if we check the type if we check
00:01:10 – the type of undefined
00:01:12 – it makes a little more sense can see
00:01:14 – this at the very bottom type of
00:01:16 – undefined is undefined
00:01:18 – oops let's clear that
00:01:23 – if we try to check if nawl is equals
00:01:29 – equals equals undefined you can see
00:01:36 – false
00:01:37 – now this equals equals equals is the
00:01:40 – identity operator so it shows that the
00:01:43 – items are different knowledge does not
00:01:44 – have the same identity is undefined but
00:01:47 – if we use the Equality operator equals
00:01:55 – equals is the Equality operator if I
00:01:57 – checked there you can see the last one
00:02:00 – is true so JavaScript does consider
00:02:02 – Nolan undefined to be equal now if I
00:02:10 – check the identity operator to see if
00:02:13 – knowledge has the same identity as k***
00:02:16 – as you expect
00:02:18 – yes it's true it shows true down here
00:02:20 – and if I check to see if not all is
00:02:23 – equal to know you will see again if you
00:02:27 – just go to the bottom true we clear that
00:02:30 – now if I say you know the ! is means not
00:02:37 – if I think not know all this is going to
00:02:41 – equal true not null is true no is its
00:02:45 – false
00:02:46 – except if u console dot log no it's just
00:02:53 – insane all however if I'm going to put
00:02:55 – you two ! in front of this and console
00:02:58 – dot log and look at the bottom
00:03:00 – false so that's why you want to use two
00:03:02 – exclamation points ! changes it to true
00:03:05 – and then to change it to false another
00:03:09 – thing interesting that if you try to add
00:03:11 – one lesson all and i run that that's
00:03:16 – yeah good actually equal one so in math
00:03:18 – knowledge basically zero
00:03:20 – however if we do 1 plus undefined
00:03:25 – it's a little different
00:03:27 – and that's going to equal in a in or not
00:03:30 – a number so undefined that you can't add
00:03:32 – anything to it because it's not a number
00:03:35 – well thanks for watching my name is Bo
00:03:37 – Carnes the code in this video and links
00:03:38 – to more resources on topic in the
00:03:40 – description don't forget to subscribe
00:03:41 – and remember use your coach for good


Video Url:
http://youtu.be/5POjWgv95Ts

Comments

comments