0% found this document useful (0 votes)
3 views1 page

Javascript T

The document provides examples of JavaScript concepts such as destructuring arrays and objects, default parameters, spread syntax, and rest parameters. It demonstrates how to extract values from arrays and objects, set default values in functions, concatenate arrays, and handle variable arguments in functions. These features are essential for modern JavaScript programming and enhance code readability and functionality.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views1 page

Javascript T

The document provides examples of JavaScript concepts such as destructuring arrays and objects, default parameters, spread syntax, and rest parameters. It demonstrates how to extract values from arrays and objects, set default values in functions, concatenate arrays, and handle variable arguments in functions. These features are essential for modern JavaScript programming and enhance code readability and functionality.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

//DESTRUCTURING ARRAYS AND OBJECTS

const food = ['rice','beans','plantain','oks']


const[bestfood,davidbest,mamabest] = food
console.log(bestfood)

//DESTRUCTURING OBJECTS
const loctechstudents = {
name:"sunday",
age:23,
phone:08168858170,
gender:"male",
isundergraduate:true
}
const newAge = 45
const{name,newAge:age} = loctechstudents
console.log(newAge)

//DEFAULT PARAMETER
function add(y,x=30){
return y+x
}

//SPRREAD
//spread is not a call back function , but a syntax in modern javascript that helps
us to spread iterable element such as array and string
//it can help us spred strings

console.log(...'joseph is a programmer')
console.log('joseph')

///how spread works with array


//spread can help us concatenate arrays

const cars = ['rover','toyota','bmw']

const newcars = ['ford','tesla','benz']


const allcars = [...cars,...newcars]
console.log(cars.concat(newcars))
console.log(allcars)
//it can also help spread objects in array , mostly used in node.js with embedded
javascript

//REST
function occasion (chairman,mother,...others){
console.log(`you are too much ${chairman},our lovely mother${mother} thsnk
you, and to ${others} thanks for coming`)
}

You might also like