Created
November 2, 2018 13:34
-
-
Save douglaspetrin/511291483d14b7befae5cbc2fe5ef132 to your computer and use it in GitHub Desktop.
JS Bin // source https://jsbin.com/goqenet
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width"> | |
<title>JS Bin</title> | |
</head> | |
<body> | |
<script id="jsbin-javascript"> | |
//Spread operator in array | |
'use strict'; | |
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; | |
var numbers = [1, 2, 3]; | |
var newNumbers = [].concat(numbers, [4]); | |
console.log(newNumbers); | |
//Spread operator in objects | |
var person = { | |
name: 'Doug' | |
}; | |
var newPerson = _extends({}, person, { | |
age: 28 | |
}); | |
console.log(newPerson); | |
//Rest Operator | |
var filter = function filter() { | |
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { | |
args[_key] = arguments[_key]; | |
} | |
return args.filter(function (el) { | |
return el === 1; | |
}); | |
}; | |
console.log(filter(1, 2, 3)); | |
/* using the filter() we got to pass an element(el) and call arrow func (=>) | |
and aks if it is equal (===) to 1 | |
=== checks for type and value; | |
filter() is a builtin method; | |
*/ | |
</script> | |
<script id="jsbin-source-javascript" type="text/javascript">//Spread operator in array | |
const numbers = [1,2,3]; | |
const newNumbers = [...numbers, 4]; | |
console.log(newNumbers); | |
//Spread operator in objects | |
const person = { | |
name: 'Doug' | |
}; | |
const newPerson = { | |
...person, | |
age: 28 | |
} | |
console.log(newPerson); | |
//Rest Operator | |
const filter = (...args) => { | |
return args.filter(el => el ===1); | |
} | |
console.log(filter(1,2,3)); | |
/* using the filter() we got to pass an element(el) and call arrow func (=>) | |
and aks if it is equal (===) to 1 | |
=== checks for type and value; | |
filter() is a builtin method; | |
*/ | |
</script></body> | |
</html> |
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
//Spread operator in array | |
'use strict'; | |
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; | |
var numbers = [1, 2, 3]; | |
var newNumbers = [].concat(numbers, [4]); | |
console.log(newNumbers); | |
//Spread operator in objects | |
var person = { | |
name: 'Doug' | |
}; | |
var newPerson = _extends({}, person, { | |
age: 28 | |
}); | |
console.log(newPerson); | |
//Rest Operator | |
var filter = function filter() { | |
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { | |
args[_key] = arguments[_key]; | |
} | |
return args.filter(function (el) { | |
return el === 1; | |
}); | |
}; | |
console.log(filter(1, 2, 3)); | |
/* using the filter() we got to pass an element(el) and call arrow func (=>) | |
and aks if it is equal (===) to 1 | |
=== checks for type and value; | |
filter() is a builtin method; | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment