Skip to content

Instantly share code, notes, and snippets.

@dharavp
Created September 1, 2017 06:54
Show Gist options
  • Save dharavp/c0772ccd811f8a91267e49fc92f7e570 to your computer and use it in GitHub Desktop.
Save dharavp/c0772ccd811f8a91267e49fc92f7e570 to your computer and use it in GitHub Desktop.
JS Bin // source https://jsbin.com/wahoralani
<!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">
'use strict';
var mul = function mul() {
console.log(arguments);
};
mul(2, 3, 4, 5);
//sum of all dynamic array item
var sum = function sum() {
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
return args.reduce(function (prev, curr) {
return prev + curr;
});
};
console.log(sum(2, 3, 4, 5));
//find max number from array
var number = [4, 3, 2, 8];
var max = Math.max.apply(null, number);
console.log(max);
//concat two array
var numbers = [4, 6, 3, 8];
var newNumbers = [3, 4, 6].concat(numbers, [7, 2]);
console.log(newNumbers);
//Destructuring
var person = { name: 'abc',
age: 30 };
var personAge = person.age;
console.log(personAge);
var arrayNumber = [3, 5, 6, 7, 8];
var first = arrayNumber[0];
var remaining = arrayNumber.slice(1);
console.log(first, remaining);
</script>
<script id="jsbin-source-javascript" type="text/javascript">let mul=function(){
console.log(arguments);
};
mul(2,3,4,5);
//sum of all dynamic array item
let sum = function(...args){
return args.reduce((prev,curr) => prev+curr);
};
console.log((sum(2,3,4,5)));
//find max number from array
let number=[4,3,2,8];
let max = Math.max.apply(null,number);
console.log(max);
//concat two array
let numbers=[4,6,3,8];
let newNumbers=[3,4,6,...numbers,7,2];
console.log(newNumbers);
//Destructuring
let person = {name:'abc',
age:30};
let {age:personAge} = person;
console.log(personAge);
let arrayNumber = [3,5,6,7,8];
let[first,...remaining]=arrayNumber;
console.log(first,remaining);</script></body>
</html>
'use strict';
var mul = function mul() {
console.log(arguments);
};
mul(2, 3, 4, 5);
//sum of all dynamic array item
var sum = function sum() {
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
return args.reduce(function (prev, curr) {
return prev + curr;
});
};
console.log(sum(2, 3, 4, 5));
//find max number from array
var number = [4, 3, 2, 8];
var max = Math.max.apply(null, number);
console.log(max);
//concat two array
var numbers = [4, 6, 3, 8];
var newNumbers = [3, 4, 6].concat(numbers, [7, 2]);
console.log(newNumbers);
//Destructuring
var person = { name: 'abc',
age: 30 };
var personAge = person.age;
console.log(personAge);
var arrayNumber = [3, 5, 6, 7, 8];
var first = arrayNumber[0];
var remaining = arrayNumber.slice(1);
console.log(first, remaining);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment