0% found this document useful (0 votes)
3 views

Some handy tips and tricks of JavaScript!

The document provides a concise overview of JavaScript functions, array methods, and string manipulation techniques. It includes examples of regular and arrow functions, various array operations like concat, map, and reduce, as well as string concatenation methods. The content is aimed at helping users quickly reference JavaScript syntax and functionalities.

Uploaded by

shivakrishna1j92
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

Some handy tips and tricks of JavaScript!

The document provides a concise overview of JavaScript functions, array methods, and string manipulation techniques. It includes examples of regular and arrow functions, various array operations like concat, map, and reduce, as well as string concatenation methods. The content is aimed at helping users quickly reference JavaScript syntax and functionalities.

Uploaded by

shivakrishna1j92
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

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

You might also like