Beginning JavaScript Flashcards
(438 cards)
Where should your scripts / script tags always go?
At the bottom of your body tag, because for you to access elements on the page, they first must have loaded onto the page.
What, in folder symbol language, is “this folder”
./
What’s the downside of multiple script tags in the same file?
Every time the browser hits a script tag it will go off and download and parse that file.
What should you do instead of having multiple script tags within the same HTML document?
Either bundle your files into one JS file or employ code-splitting.
What is code splitting?
When you split JS files into multiple smaller files and then have them load on demand.
What is the keyboard shortcut within the browser to inspect an element?
Cmd + Shift + C, then you can hold it while hovering over the element you need.
What is the keyboard shortcut to open the console directly in the browser?
Option + Cmd + J
Why don’t we have to type ‘use strict’ every time?
Because it is enforced by default in JS modules, which is how almost all modern JS will be written.
What is the difference in scope between var, let, and const?
let and const are block scoped while var is function scoped.
What is Wes’s opinion of when to use var, let, or const?
By default always use const, once it needs to change switch it to let…never use var.
What are the 7 types in JavaScript?
BS BONUS - BigInt, Symbol, Boolean, Object, Null, Undefined, String
Everything in javascript is an….
Object.
What is the only non-primitive Type?
Object
Which type always gives us a guaranteed unique identifier?
Symbols.
How do you disable eslint on a particular file?
Just make a comment at the top:
/* eslint-disable */
How do you disable eslint for just one line?
Make a comment above the line
/* eslint-disable-line */
How can use a single quote within single quotes?
Escape it with a backslash /
This tells the interpreter to take what follows as text, not as javascript.
‘he/’s so cool’
What does it mean to say the plus sign is ‘loaded’?
It can both add and concatenate and if you use different types, you could be in for a world of hurt and misunderstanding, bugs and misery.
How should you store money?
Just in cents, so that you have a whole number that is easy to do math with rather than a floating point integer that is prone to errors, then just divide by 100 when you need to display it.
What is the difference between undefined and null?
Undefined is when a variable has been created but never defined, null is when something has explicitly been set to nothing. It’s the difference between Cher being born with only one name (undefined) and Teller of Penn & Teller legally setting his name to just Teller (marking his last name as null explicitly)
What is the difference between using a double and triple equal sign?
“It’s almost always wrong to use the double equal sign to test equality.
Triple equal tests that the value and the type are the same, whereas a double equal sign tests only that the value is the same, not the type.
So, ““10”” == 10 is true, but ““10”” === 10 is false because they are different types.
“
What is the tab keyword to get lorem ipsum text with the emmet extension?
lorem500 (or however many words you would like)
What built in JS function will let you move the navbar to any x, y coordinate on the page?
scrollTo - it either accepts an x and y coordinate as the params, or else accepts an option object which would have the position defined by top, left, bottom.
What argument can you pass if you need a function parameter to fall back to its default (but, for example, it’s in the middle of the argument list, so you can’t just skip it)
If you pass undefined, then the function will fall back to its default.
