Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Spread - Operator
- const numbers = [1,1,2,3,5,8,13];
- const maxFromArray = Math.max(...numbers); // returns 13
- const num1 = [1,2,3];
- const num2 = [4,5,6];
- // this is also possible with objects
- const fullnum = [...num1, ...num2]; // returns [1,2,3,4,5,6]
- // Rest - Operator
- const makeArray = (...args) => args;
- const myArrayFromFunction = makeArray(1,2,3,4); // return [1,2,3,4,5]
- // Destructuring
- // with arrays
- const myHobbies = ['Cooking', 'Sports'];
- const [hobby1, hobby2] = myHobbies;
- console.log(hobby1); // return 'Cooking'
- console.log(hobby2); // return 'Sports'
- // with objects
- const userData = {
- userName: 'Igor',
- age: 23
- };
- const { userName, age} = userData;
- console.log(userName) // return 'Igor'
- console.log(age) // return 23
- // Template Literals
- const string1 = 'Hello this ist the first part of a string.';
- const string2 = 'And this is the second part.';
- const fullString = `${string1} ${string2} I can also add here some text`;
- console.log(fullString); // returns 'Hello this ist the first part of a string. And this is the second part. I can also add here some strings'
Add Comment
Please, Sign In to add comment