javascript ec6 よく使うやつ

javascript ec6 よく使うやつ



 let val = `テンプレート文字列とは
  ヒアドキュメントのようなもの`;
  console.log(val);

let name = '小川';
let str  = `My name is ${name}`;
console.log(str);

//分割代入
let [namae,age]=['ささき',35];
console.log(namae , age);

// js のforeach文
names = ['sato','ito','goto'];
for (let value of names){
  console.log(value);
}

// 可変長引数
function sum(...prop){
  var t = 0;
  for(let num of prop)
    t += num ;
  return t ;  
}
console.log( sum( 2 ,4 ,1 ) );
console.log( sum( 2 ,4 ) );

/*
無名関数をつくるアロー関数 
*/
var area = (x,y) => {
  console.log( x * y );
}
area(12,4);

// 一行の処理だけなら{}がいらない。 引数が一つなら()も省略可 
var squareArea = val => val ** 2
 console.log(squareArea(9));

太平洋

Website:


Notice: ob_end_flush(): failed to send buffer of zlib output compression (1) in /var/www/html/wp/wp-includes/functions.php on line 5107

Notice: ob_end_flush(): failed to send buffer of zlib output compression (1) in /var/www/html/wp/wp-includes/functions.php on line 5107