Skip to content

Instantly share code, notes, and snippets.

@svngoku
Created December 26, 2018 01:08
Show Gist options
  • Select an option

  • Save svngoku/1bdedb94900eea5325e6f9b4b85de73e to your computer and use it in GitHub Desktop.

Select an option

Save svngoku/1bdedb94900eea5325e6f9b4b85de73e to your computer and use it in GitHub Desktop.
ES6Module created by svngoku - https://repl.it/@svngoku/ES6Module
/* ES6 Modules */
/* strings */
let str = 'Hello Papy';
console.log(str.endsWith('Papy')); // true
/* Array */
let a = [ 1,2,3,4,5];
console.log(a.find(e => e % 3 === 0)); // 3
console.log(a.findIndex(e => e % 3 === 0)); // 2
[1,2,3].fill(4); // [4 ,4 ,4]
[1,2,3].copyWithin(0,2); // [3, 2, 3]
/* Numbers */
/*
Number.EPSILON
Number.MAX_SAFE_INTEGER
Number.MIN_SAFE_INTEGER
Number.isNaN()
Number.isFinite()
Number.isInteger()
Number.isSafeInteger()
Number.parseInt()
Number.parseFloat()
*/
/* Maths and methods */
/*
Math.acosh()
Math.asinh()
Math.atanh()
Math.cosh()
Math.sinh()
Math.tanh()
Math.cbrt()
Math.clz32()
Math.expm1()
Math.fround()
Math.hypot()
Math.imul()
Math.log10()
Math.log1p()
Math.log2()
Math.sign()
Math.trunc()
Math.floor()
*/
/* Object */
// first part : simple assignment
let o1 = { foo: 'bar'};
let o2 = { bar: 'foo'};
let o3 = Object.assign({}, o1, o2);
console.log(o3); // { foo: 'bar', bar: 'foo' }
// second part
let o4 = {
foo : 'test',
bar : [1,2,3]
};
let o5 = Object.assign({}, o4);
o5.bar.push(4);
console.log(o4.bar);
/***** end ******/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment