Q JavaScript
@thecodecrumbs ~$ '
www.codecrumbs.com ~
Q JavaScript
// Regular Function
let myCustomFunction = function() {}
// Arrow Function
let myCustomFunction = () => {}
@thecodecrumbs Q1
www.codecrumbs.com
Q JavaScript
Array Cheat Sheet
[ 'a' , 'b' ] . concat ( [ 'c' ]) //['a','b','c']
[ I a I I 'b' l . join ( [ ' - ' l) //'a-b'
[ ' a ' ' ' b , 'c' ] .slice ( 1 ) //['b', 'c']
'
[ I a I I ,b' 'c' ] .indexOf ( 'b' )
'
[ I a I / ' b' 'b' ] .lastindexOf ( 'b' )
'
[ 1 , 2 , 3 ] .map ( x => x * 2) //[2, 4, 6]
[ 2 , 15 , 3 ] . sort() //[15, 2, 3]
[ 1 , 2 , 3 ] . reverse () //[3, 2, 1]
@thecodecrumbs
www.codecrumbs.com
Q JavaScript
Array Cheat Sheet
[1 , 2 , 3 ] . reduce ( ( x, y ) => x * y)
[1 , 2 , 3 ] .length
[1 , 2 , 3 ] . every ( x => x < 10 ) //true
[1 , 2 , 3 ] .some (x => x < 2) //true
canst arr = [ 1 ' 2 , 3 l
canst x=a rr . shift() //arr=[2, 3 l , x=1
canst x=a rr .unshift( 9) //arr=[9, 1 ' 2, 3 l , x=4
canst x=a rr . pop() //arr=[ 1 ' 2 l , x=3
canst x=arr .push( S) //arr=[1, 2, 3, s l , x=4
@thecodecrumbs
www.codecrumbs.com
Q JavaScript
String Methods
The + Operator
canst str = ' Hello ' + ' ' + ' World '
//Hello World
Array.join( )
[ 'Hello ' , ' ' , ' World' ] .join ( '' )
//Hello World
@thecodecrumbs
www.codecrumbs.com
Q JavaScript
String Methods
String.concat()
canst st r1 = ' Hello '
canst st r2 = str 1 . concat ( ' ' World' )
//Hello World
Template Literals
canst str 1 = ' Hello'
' ${ st r1 } World "
//Hello World
@thecodecrumbs
www.codecrumbs.com
How many do
you know?
@thecodecrumbs
www.codecrumbs.com