9
7

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.

JavaScript ショートハンドまとめ

Posted at

JavaScriptショートハンドまとめ

更新履歴

  • 2015/08/19 作成

文字列が含まれていたら

var someStr = 'abcdefg';

/* Long */
if (someStr.indexOf('abc') != -1) {
  // => Found
} else {
  // => Not Found
}

/* Shorten */
if (~someStr.indexOf('abc')) {
  // Found
} else {
  // Not Found
}

文字列から数値への型キャスト

var someStr = '123';

/* Long */
parseInt(someStr, 10);

/* Shorten */
+someStr;

数値から文字列への型キャスト

var someNum = 123;

/* Long */
someNum.toString();

/* Shorten */
''+someNum;
9
7
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
9
7

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?