# Front-End Interview
# Good links
- 10 questions you should know in JS
- Common interview questions, by subject
- Best frontend JS questions
- FE Interview handbook
- Useful FrontendMasters path for preparing
# Random notes
flex-grow: number
defines the space each flex element occupies. If not written manually, it is set to1
, so all the items occupy the same fraction of space.- Decorative images should always have an empty
alt
attribute alt
attribute in images is really important for SEO purposes- Cache busting is to force the browser to download new files that may have been stored on the client side. Can be done by appending
?=v2
to the script in our file, for example @media
properties ->all
,screen
,print
,speech
- Primitives (strings and numbers) are compared by their value, while objects are compared by their reference (location in memory)
- XSS is a cross-site scripting attack. The attacker injects malicious code to our site, client-side. To prevent it:
- use
textContent
instead ofinnerHTML
- escape HTML tags on the server
- use
- About JS expressions and statements ->
If you can print it or assign it to a variable, itās an expression. If you canāt, itās a statement.
- 6 FALSY VALUES:
NaN
,0
,undefined
,false
,''
,null
- Semicolons are not required in Javascript, only in some edge cases. The interpreter will add them automatically.
- HOISTING:
No matter where functions and variables are declared, they are moved to the top of their scope regardless of whether their scope is global or local.
- JS ASI: Automatic Semicolon Insertion that can lead to bugs.
- Difference between
defer
andasync
in a<script>
tag:The
defer
attribute downloads the script while the document is still parsing but waits until the document has finished parsing before executing it.The
async
attribute downloads the script during parsing the document but will pause the parser to execute the script before it has fully finished parsing.
rel="noopener"
prevents opened links from manipulating the source page. Should always put in<a>
tags.- Javascript data types:
- Primitive
- Boolean
- Null
- Undefined
- Number
- String
- Symbol (newly added)
- Non-primitive
- Object
- Array
- Date
- function
- Primitive
- The
Object.create()
method creates a new object, using an existing object to provide the newly created object's__proto__
. - The
Promise
object represents the eventual completion (or failure) of an asynchronous operation, and its resulting value. - Difference between
null
andundefined
->undefined
is used when the nothing is not known, andnull
is used when the nothing is known. - CSS specificity:
- Value matrix:
[inline, id, class/pseudo-class/attribute, tag/pseudo-element]
- In cases of equal specificity, the last rule is applied
- Value matrix:
- Storing data in a user's browser. Before it was done with cookies, but these methods are faster and allow more size (5mb)
localStorage
- Data is permanent
sessionStorage
- When the user closes window or tab, the data is deleted
ā JavaScript Algorithms Gatsby ā