Skip to content

Instantly share code, notes, and snippets.

@douglaspetrin
Created November 2, 2018 13:23
Show Gist options
  • Save douglaspetrin/d0d38ef986684757d2f60538f8547f06 to your computer and use it in GitHub Desktop.
Save douglaspetrin/d0d38ef986684757d2f60538f8547f06 to your computer and use it in GitHub Desktop.
JS Bin // source https://jsbin.com/vijikig
<!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 & Rest Operators (...)
// Spread is usedto split up array elements or objects properties:
"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; };
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) arr2[i] = arr[i]; return arr2; } else { return Array.from(arr); } }
var newArray = [].concat(_toConsumableArray(oldArray), [1, 2]);
var newObject = _extends({}, oldObject, { newProp: 5 });
// Rest is used to merge a list of function arguments into an array:
function sortArgs() {
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
return args.sort();
}
</script>
<script id="jsbin-source-javascript" type="text/javascript">// Spread & Rest Operators (...)
// Spread is usedto split up array elements or objects properties:
const newArray = [...oldArray, 1, 2]
const newObject = {...oldObject, newProp:5 }
// Rest is used to merge a list of function arguments into an array:
function sortArgs(...args) {
return args.sort()
}
</script></body>
</html>
// Spread & Rest Operators (...)
// Spread is usedto split up array elements or objects properties:
"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; };
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) arr2[i] = arr[i]; return arr2; } else { return Array.from(arr); } }
var newArray = [].concat(_toConsumableArray(oldArray), [1, 2]);
var newObject = _extends({}, oldObject, { newProp: 5 });
// Rest is used to merge a list of function arguments into an array:
function sortArgs() {
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
return args.sort();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment