Skip to content

Instantly share code, notes, and snippets.

View shahab570's full-sized avatar

MD SHAHAB UDDIN shahab570

View GitHub Profile
var a = "first";
var b = "second";
var [a, b] = [b, a];
console.log(a); //second
console.log(b); //first
let [firstName = prompt("What is your name?"), surname = prompt("surname?")] =["John"];
alert(firstName);
alert(surname);
var [first="This", second = "is"] =["hello"];
console.log(first); //hello
console.log(second); //is
function words() {
return ["This", "is", "john", "Doe"];
}
var [first, second] = words();
console.log(first); //This
console.log(second); //is
var words = ["This", "is", "john", "Doe"];
var [first, ...last] = words;
console.log(last); //["is","john","Doe"];
var words = ["This", "is", "john", "Doe"];
var [first, , third] = words;
console.log(third); //john
var [first, second, third] = "USA";
console.log(first); //U
console.log(second); //S
console.log(third); //A
var words = ["This", "is", "john", "Doe"];
var [first, second] = words;
console.log(first); //This
console.log(second); //is
var words = ["This", "is", "john", "Doe"];
var first = words[0];
var second = words[1];
console.log(first); //This
console.log(second); // is
let take_bath = new Promise((resolve, reject) => {
setTimeout(() => {
resolve("I have finished my bath");
}, 5000);
});
let eat = new Promise((resolve, reject) => {
setTimeout(() => {
resolve("I have finished eating");
}, 3000);