This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// simple function | |
function add(a,b){ | |
return a+b | |
} | |
//similar arrow function | |
const add = (a,b) => { | |
return a+b | |
} | |
//shorten it more | |
const add = (a,b) => a+b |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var saying="hello \n I need some juice" // old way | |
var saying = `hello | |
I need some juice`; // es6 way | |
////////////////////////////////////////////// | |
var firstName = 'Tom'; | |
var lastName = 'Hanks'; | |
var greetings = 'Hi'; | |
var age = '63'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// map() goes through every item and return it or perform some function | |
const array = [2,3,6,9,12]; | |
array.map((item)=>item*item); | |
//[4, 9, 36, 81, 144] output | |
const cars = ['toyota', 'alto', 'civic']; | |
cars.map((item)=>item.toUpperCase()) | |
//['TOYOTA','ALTO','CIVIC'] output |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
///filter() method find certain items and filter other according to condition you give | |
const record = ['John', 'Adams', 'faiza'] // let me filter myself out | |
record.filter((item) => {return item !=='faiza'}) | |
//['John', 'Adams'] |