Professional Documents
Culture Documents
30 Seconds of Interviews Copy 2
30 Seconds of Interviews Copy 2
11 12 1
10 2
9 3
8 4
7 6 5
alt
alt
alt
alt
https://30secondsofinterviews.org 1/96
31/08/2023, 22:04 30 seconds of interviews
alt
. alt
/* block component */
.block {
}
/* element */
.block__element {
}
/* modifier */
.block__element--modifier {
}
<nav class="navbar">
<a href="/" class="navbar__link navbar__link--active"></a>
<a href="/" class="navbar__link"></a>
https://30secondsofinterviews.org 2/96
31/08/2023, 22:04 30 seconds of interviews
navbar navbar__link
navbar navbar__link--active
navbar__link
is-*
.navbar__link.is-active {
}
https://30secondsofinterviews.org 3/96
31/08/2023, 22:04 30 seconds of interviews
src="js/script.js" src="js/script.js?v=2"
https://30secondsofinterviews.org 4/96
31/08/2023, 22:04 30 seconds of interviews
==
===
===
==
==
https://30secondsofinterviews.org 5/96
31/08/2023, 22:04 30 seconds of interviews
col-{n} / 12
<div class="row">
<div class="col-2"></div>
<div class="col-7"></div>
<div class="col-3"></div>
</div>
flex-grow
https://30secondsofinterviews.org 6/96
31/08/2023, 22:04 30 seconds of interviews
.row {
display: flex;
}
.col-2 {
flex: 2;
}
.col-7 {
flex: 7;
}
.col-3 {
flex: 3;
}
<header>
<footer>
<header> <footer>
<body>
<article> <section>
https://30secondsofinterviews.org 7/96
31/08/2023, 22:04 30 seconds of interviews
<header>
<article>
<section>
<footer>
<form> <table>
https://30secondsofinterviews.org 8/96
31/08/2023, 22:04 30 seconds of interviews
@media
all
print
screen
speech
i++
++i
let i = 0
i++ // 0
// i === 1
https://30secondsofinterviews.org 9/96
31/08/2023, 22:04 30 seconds of interviews
let i = 0
++i // 1
// i === 1
Promise
{} /* */
const tree = (
<div>
{/* Comment */}
<p>Text</p>
https://30secondsofinterviews.org 10/96
31/08/2023, 22:04 30 seconds of interviews
</div>
)
https://30secondsofinterviews.org 11/96
31/08/2023, 22:04 30 seconds of interviews
useState()
this
https://30secondsofinterviews.org 12/96
31/08/2023, 22:04 30 seconds of interviews
defer
DOMContentLoaded defer
async
async
src
<script src="myscript.js"></script>
<script src="myscript.js" defer></script>
<script src="myscript.js" async></script>
defer <head>
defer
async
defer
DOMContentLoaded
batches
/**
It accepts two objects as arguments: the first object is the recipe
for the food, while the second object is the available ingredients.
Each ingredient's value is a number representing how many units the
https://30secondsofinterviews.org 13/96
31/08/2023, 22:04 30 seconds of interviews
`batches(recipe, available)`
*/
Object.keys()
Array.prototype.map()
https://30secondsofinterviews.org 14/96
31/08/2023, 22:04 30 seconds of interviews
NaN
0
...
Math.min()
Math.floor()
bind
Function.prototype.bind
function example() {
console.log(this)
}
const boundExample = bind(example, { a: true })
boundExample.call({ b: true }) // logs { a: true }
...
fn Function.prototype.apply
https://30secondsofinterviews.org 15/96
31/08/2023, 22:04 30 seconds of interviews
setState
setState
setState
setState
https://30secondsofinterviews.org 16/96
31/08/2023, 22:04 30 seconds of interviews
function onClick() {
console.log("The user clicked on the page.")
}
document.addEventListener("click", onClick)
map
className class
class className
https://30secondsofinterviews.org 17/96
31/08/2023, 22:04 30 seconds of interviews
element.className = "hello"
const element = {
attributes: {
class: "hello"
}
}
class
class
className
className class
...
https://30secondsofinterviews.org 18/96
31/08/2023, 22:04 30 seconds of interviews
const obj = { a: 1, b: 2 }
const shallowClone = { ...obj }
JSON.parse(JSON.stringify(obj))
Object.assign({}, obj)
Object.keys(obj).reduce((acc, key) => (acc[key] = obj[key],
acc), {})
== ===
https://30secondsofinterviews.org 19/96
31/08/2023, 22:04 30 seconds of interviews
true
if (
Object.prototype.toString.call(obj1) !==
Object.prototype.toString.call(obj2) ||
typeof obj1 !== "object"
) {
return false
}
https://30secondsofinterviews.org 20/96
31/08/2023, 22:04 30 seconds of interviews
true
)
: true
return (
obj1Props.length === obj2Props.length &&
prototypesAreEqual &&
obj1Props.every(prop => isDeepEqual(obj1[prop], obj2[prop]))
)
}
http://mydomain.com
http://yourdomain.com
XMLHttpRequest fetch
https://30secondsofinterviews.org 21/96
31/08/2023, 22:04 30 seconds of interviews
Content
content-box width
content-box height
Padding
Border
border-box width border-box height
https://30secondsofinterviews.org 22/96
31/08/2023, 22:04 30 seconds of interviews
https://30secondsofinterviews.org 23/96
31/08/2023, 22:04 30 seconds of interviews
document.getElementById() document.querySelector()
innerHTML
em rem
em rem font-size
em font-size
rem font-size
html
font-size 16px
em rem
https://30secondsofinterviews.org 24/96
31/08/2023, 22:04 30 seconds of interviews
Event.target
document.querySelectorAll("button").forEach(button => {
button.addEventListener("click", handleButtonClick)
})
document.addEventListener("click", e => {
if (e.target.closest("button")) {
https://30secondsofinterviews.org 25/96
31/08/2023, 22:04 30 seconds of interviews
handleButtonClick()
}
})
let x = 0
function declaration() {}
if (true) {
}
https://30secondsofinterviews.org 26/96
31/08/2023, 22:04 30 seconds of interviews
y >= 0
true false
5 + 5 // => 10
https://30secondsofinterviews.org 27/96
31/08/2023, 22:04 30 seconds of interviews
true false
false
undefined
null
""
NaN
0 +0 -0
Boolean
Boolean("") // false
Boolean([]) // true
! !
https://30secondsofinterviews.org 28/96
31/08/2023, 22:04 30 seconds of interviews
!!"" // false
!![] // true
n Array.prototype.reduce()
false
https://30secondsofinterviews.org 29/96
31/08/2023, 22:04 30 seconds of interviews
map()
forEach()
map()
forEach()
forEach()
map()
forEach()
map()
https://30secondsofinterviews.org 30/96
31/08/2023, 22:04 30 seconds of interviews
var foo = 1
var foobar = function() {
console.log(foo)
var foo = 2
}
foobar()
foo console.log
foo
console.log()
undefined 2
strict
https://30secondsofinterviews.org 31/96
31/08/2023, 22:04 30 seconds of interviews
console.log(hoist)
var hoist = "value"
var hoist
console.log(hoist)
hoist = "value"
https://30secondsofinterviews.org 32/96
31/08/2023, 22:04 30 seconds of interviews
HTML5
HTML5
HTML5 HTML5
https://30secondsofinterviews.org 33/96
31/08/2023, 22:04 30 seconds of interviews
<button onclick="handleClick()"></button>
false
preventDefault
function handleClick(e) {
e.preventDefault()
console.log("The link was clicked.")
}
https://30secondsofinterviews.org 34/96
31/08/2023, 22:04 30 seconds of interviews
<DOCTYPE>
checked="checked" checked
https://30secondsofinterviews.org 35/96
31/08/2023, 22:04 30 seconds of interviews
}
})()
privateVariable // ReferenceError
myLibrary.publicMethod() // 2
https://30secondsofinterviews.org 36/96
31/08/2023, 22:04 30 seconds of interviews
&& ? : if else
<li>
https://30secondsofinterviews.org 37/96
31/08/2023, 22:04 30 seconds of interviews
<li>
https://30secondsofinterviews.org 38/96
31/08/2023, 22:04 30 seconds of interviews
getDerivedStateFromProps
componentDidMount
shouldComponentUpdate
getSnapshotBeforeUpdate
componentDidUpdate
componentDidUpdate
componentDidUpdate
componentWillUnmount
componentDidCatch
https://30secondsofinterviews.org 39/96
31/08/2023, 22:04 30 seconds of interviews
getDerivedStateFromProps componentDidMount
getDerivedStateFromProps shouldComponentUpdate
getSnapshotBeforeUpdate componentDidUpdate
componentWillUnmount
componentDidCatch
https://30secondsofinterviews.org 40/96
31/08/2023, 22:04 30 seconds of interviews
mask("123456789") // "#####6789"
String.prototype.slice()
-4
String.prototype.padStart()
https://30secondsofinterviews.org 41/96
31/08/2023, 22:04 30 seconds of interviews
MIME type
MIME type
application/msword
https://30secondsofinterviews.org 42/96
31/08/2023, 22:04 30 seconds of interviews
console.log(data)
})
isTrue(false, callback)
isTrue(true, callback)
https://30secondsofinterviews.org 43/96
31/08/2023, 22:04 30 seconds of interviews
/*
{ stack: [Getter/Setter],
arguments: undefined,
type: undefined,
message: 'Value is not true!' }
Value was true.
*/
null undefined
undefined
null null
undefined
undefined null
undefined
null
https://30secondsofinterviews.org 44/96
31/08/2023, 22:04 30 seconds of interviews
const person = {
name: "John",
age: 50,
birthday() {
this.age++
}
}
person.birthday() // person.age === 51
new
https://30secondsofinterviews.org 45/96
31/08/2023, 22:04 30 seconds of interviews
new
this
Object.create()
const personProto = {
birthday() {
this.age++
}
https://30secondsofinterviews.org 46/96
31/08/2023, 22:04 30 seconds of interviews
}
const person = Object.create(personProto)
person.age = 50
person.birthday() // person.age === 51
Object.create()
Object.create(personProto, {
age: {
value: 50,
writable: true,
enumerable: true
}
})
https://30secondsofinterviews.org 47/96
31/08/2023, 22:04 30 seconds of interviews
arguments
myFunction.length
bind
https://30secondsofinterviews.org 48/96
31/08/2023, 22:04 30 seconds of interviews
Promise
Promise
Promise
https://30secondsofinterviews.org 49/96
31/08/2023, 22:04 30 seconds of interviews
new
Object.create()
const a = [1, 2, 3]
const b = [1, 2, 3]
const c = "1,2,3"
console.log(a == c)
console.log(a == b)
console.log true
console.log false
https://30secondsofinterviews.org 50/96
31/08/2023, 22:04 30 seconds of interviews
rel="noopener"
rel="noopener" <a>
window.opener
rel="noopener"
rel="noopener"
posts
users comments
https://30secondsofinterviews.org 51/96
31/08/2023, 22:04 30 seconds of interviews
posts
/posts/
/posts/new
/posts/:id
/posts/:id
function greet() {
return
{
message: "hello"
}
}
return
undefined
https://30secondsofinterviews.org 52/96
31/08/2023, 22:04 30 seconds of interviews
const previousLine = 3
;[1, 2, previousLine].map(n => n * 2)
const previousLine = 3
;(function() {
// ...
})()
3
3
https://30secondsofinterviews.org 53/96
31/08/2023, 22:04 30 seconds of interviews
true || false
false true
true || nonexistentFunction()
false && nonexistentFunction()
https://30secondsofinterviews.org 54/96
31/08/2023, 22:04 30 seconds of interviews
const options = {}
const setting = options.setting || "default"
setting // "default"
// Instead of:
addEventListener("click", e => {
if (e.target.closest("button")) {
handleButtonClick(e)
}
})
e.target
"button"
https://30secondsofinterviews.org 55/96
31/08/2023, 22:04 30 seconds of interviews
https://30secondsofinterviews.org 56/96
31/08/2023, 22:04 30 seconds of interviews
XMLHttpRequest setTimeout
alert
typeof typeof 0
"string"
https://30secondsofinterviews.org 57/96
31/08/2023, 22:04 30 seconds of interviews
Symbol
Array Date function object
window
https://30secondsofinterviews.org 58/96
31/08/2023, 22:04 30 seconds of interviews
var
setTimeout
i 10
https://30secondsofinterviews.org 59/96
31/08/2023, 22:04 30 seconds of interviews
})(i)
}
let
const
const myObject = {}
myObject.prop = "hello!" // No error
myObject = "hello" // Error
let const
https://30secondsofinterviews.org 60/96
31/08/2023, 22:04 30 seconds of interviews
var let
var
var const
let
<script>
https://30secondsofinterviews.org 61/96
31/08/2023, 22:04 30 seconds of interviews
textContent innerHTML
1ms
arr[arr.length - 1]
1ms
https://30secondsofinterviews.org 62/96
31/08/2023, 22:04 30 seconds of interviews
arr.filter(fn)
1000ms
arr.some(fn)
arr.sort(fn)
10000ms
sort()
https://30secondsofinterviews.org 63/96
31/08/2023, 22:04 30 seconds of interviews
1000000ms
Infinity
getData(function(a) {
getMoreData(a, function(b) {
getMoreData(b, function(c) {
getMoreData(c, function(d) {
getMoreData(d, function(e) {
https://30secondsofinterviews.org 64/96
31/08/2023, 22:04 30 seconds of interviews
// ...
})
})
})
})
})
async/await
await
https://30secondsofinterviews.org 65/96
31/08/2023, 22:04 30 seconds of interviews
findDOMNode()
findDOMNode()
render() {
return <div />
}
}
render() {
return <div ref={node => (this.node = node)} />
}
}
https://30secondsofinterviews.org 66/96
31/08/2023, 22:04 30 seconds of interviews
findDOMNode()
children
children
React.Children.map
React.Children.forEach React.Children.count
React.Children.only React.Children.toArray
function App() {
return (
<GenericBox>
<span>Hello</span> <span>World</span>
</GenericBox>
)
}
https://30secondsofinterviews.org 67/96
31/08/2023, 22:04 30 seconds of interviews
https://30secondsofinterviews.org 68/96
31/08/2023, 22:04 30 seconds of interviews
<p> <div>
div ~ p {
background-color: blue;
https://30secondsofinterviews.org 69/96
31/08/2023, 22:04 30 seconds of interviews
<p>
<div>
div + p {
background-color: red;
}
https://30secondsofinterviews.org 70/96
31/08/2023, 22:04 30 seconds of interviews
static getDerivedStateFromError()
componentDidCatch().
https://30secondsofinterviews.org 71/96
31/08/2023, 22:04 30 seconds of interviews
render() {
if (this.state.hasError) {
// You can render any custom fallback UI
return <h1>Something went wrong.</h1>
}
return this.props.children
}
}
click mouseenter
document.addEventListener("click", function(event) {
// This callback function is run when the user
// clicks on the document.
})
https://30secondsofinterviews.org 72/96
31/08/2023, 22:04 30 seconds of interviews
on emit
outline: 0;
https://30secondsofinterviews.org 73/96
31/08/2023, 22:04 30 seconds of interviews
box-shadow
:focus-visible
render() {
return (
<React.Fragment>
<ChildA />
<ChildB />
<ChildC />
</React.Fragment>
);
}
https://30secondsofinterviews.org 74/96
31/08/2023, 22:04 30 seconds of interviews
<ChildA />
<ChildB />
<ChildC />
</>
);
}
.map
.reduce
https://30secondsofinterviews.org 75/96
31/08/2023, 22:04 30 seconds of interviews
localStorage
sessionStorage
localStorage sessionStorage
https://30secondsofinterviews.org 76/96
31/08/2023, 22:04 30 seconds of interviews
localStorage
sessionStorage
sessionStorage
localStorage sessionStorage
sessionStorage
sessionStorage
localStorage
sessionStorage
https://30secondsofinterviews.org 77/96
31/08/2023, 22:04 30 seconds of interviews
https://30secondsofinterviews.org 78/96
31/08/2023, 22:04 30 seconds of interviews
https://30secondsofinterviews.org 79/96
31/08/2023, 22:04 30 seconds of interviews
this
this
Function.prototype.bind()
this
constructor(props) {
super(props);
this.handleClick = this.handleClick.bind(this);
}
handleClick() {
// Perform some logic
}
bind
constructor
handleClick = () => {
console.log('this is:', this);
}
render() {
return (
<button onClick={this.handleClick}>
Click me
</button>
);
}
https://30secondsofinterviews.org 80/96
31/08/2023, 22:04 30 seconds of interviews
this
shouldComponentUpdate PureComponent
bind
https://30secondsofinterviews.org 81/96
31/08/2023, 22:04 30 seconds of interviews
String.prototype
Array.prototype
NaN
NaN
NaN
isNaN() Number.isNaN()
const isNaN = x => x !== x
https://30secondsofinterviews.org 82/96
31/08/2023, 22:04 30 seconds of interviews
pipe
...
Array.prototype.reduce()
https://30secondsofinterviews.org 83/96
31/08/2023, 22:04 30 seconds of interviews
ReactDOM.createPortal(child, container)
child
container
isRequired
https://30secondsofinterviews.org 84/96
31/08/2023, 22:04 30 seconds of interviews
propTypes
render() {
return (
<h1>Welcome, {this.props.name}</h1>
<h2>Age, {this.props.age}
)
}
}
propTypes
propTypes
https://30secondsofinterviews.org 85/96
31/08/2023, 22:04 30 seconds of interviews
setInnerHTML
https://30secondsofinterviews.org 86/96
31/08/2023, 22:04 30 seconds of interviews
const comments = [
{ id: 1, parent_id: null, text: "First reply to post." },
{ id: 2, parent_id: 1, text: "First reply to comment #1." },
{ id: 3, parent_id: 1, text: "Second reply to comment #1." },
{ id: 4, parent_id: 3, text: "First reply to comment #3." },
{ id: 5, parent_id: 4, text: "First reply to comment #4." },
{ id: 6, parent_id: null, text: "Second reply to post." }
]
nest(comments)
/*
[
{ id: 1, parent_id: null, text: "First reply to post.", children:
{ id: 6, parent_id: null, text: "Second reply to post.", children
]
*/
filter()
map()
https://30secondsofinterviews.org 87/96
31/08/2023, 22:04 30 seconds of interviews
React.createRef()
ref
ref
render() {
return <div ref={this.myRef} />
}
}
https://30secondsofinterviews.org 88/96
31/08/2023, 22:04 30 seconds of interviews
React.createRef()
ref
Array.isArray
https://30secondsofinterviews.org 89/96
31/08/2023, 22:04 30 seconds of interviews
this
this
this
call() apply() bind()
this
call()
this
this
this
var myObject = {
property: this,
regularFunction: function() {
return this
},
arrowFunction: () => {
return this
},
iife: (function() {
return this
})()
}
myObject.regularFunction() // myObject
myObject["regularFunction"]() // my Object
https://30secondsofinterviews.org 90/96
31/08/2023, 22:04 30 seconds of interviews
this
document.body.addEventListener("click", function() {
console.log(this) // document.body
})
this
class Example {
constructor() {
console.log(this) // myExample
}
}
const myExample = new Example()
this
this
https://30secondsofinterviews.org 91/96
31/08/2023, 22:04 30 seconds of interviews
var obj = {
arr: [1, 2, 3],
doubleArr() {
return this.arr.map(function(value) {
// this is now this.arr
return this.double(value)
})
},
double() {
return value * 2
}
}
obj.doubleArr() // Uncaught TypeError: this.double is not a functio
this window
this undefined
Function.prototype.call Function.prototype.apply
this call
apply
Function.prototype.bind
this
this
function
this
https://30secondsofinterviews.org 92/96
31/08/2023, 22:04 30 seconds of interviews
data
https://30secondsofinterviews.org 93/96
31/08/2023, 22:04 30 seconds of interviews
'use strict'
'use strict'
eval() arguments
this this
null undefined
delete
https://30secondsofinterviews.org 94/96
31/08/2023, 22:04 30 seconds of interviews
<div class="counter">
<h1>0</h1>
<button>-</button>
<button>+</button>
</div>
{
nodeName: "div",
attributes: { class: "counter" },
children: [
{
nodeName: "h1",
attributes: {},
children: [0]
},
{
nodeName: "button",
attributes: {},
children: ["-"]
},
{
nodeName: "button",
attributes: {},
children: ["+"]
}
]
}
https://30secondsofinterviews.org 95/96
31/08/2023, 22:04 30 seconds of interviews
https://30secondsofinterviews.org 96/96