1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

できるエンジニアはconsole.log()を上手く使いこなしている。(初心者向け)

1
Last updated at Posted at 2019-08-22

はじめに

できるエンジニアはconsole.log()を使いこなしているとのこと。
未経験から上がったような人向けです。
console.log()の配置場所、中身の書き方など参考すべき記事やアドバイスありましたら教えてください。

個人でのやりやすさが肝だと思うのでいろんな人の意見を聞きたいです。
node.jsを触っていて、フロントはさっぱりです。

デバック時のconsole.logの書き方
 

.js
// DBからデータ取得時にはエラーが起きにくいので、データ取得の関数の後に`console.log()`を。
// DB更新時のエラーは起きやすいから、DB変更の関数の前後にconsole.log()を仕込む。 
result1 = getDate();
console.log('getDate: ' result);

console.log('addDate');
result2 = addDate();
console.log('addedDate: ' result2);


//簡潔な書き方
console.log(`checkdata: ${result}`)  console.log('checkdata: ', result) 

// 変数の型がわかる。
console.log(type of 変数) //stringなど。

//result1,2みたいな書き方は意図が読めず関数としては最悪なので実際には書かないでください。
1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?