LoginSignup
5
5

More than 5 years have passed since last update.

JavaScriptのオブジェクトのkeyにnullが使える話

Posted at
var hash = {};
hash.null = "123";       // プロパティ名として有効
console.log(hash.null);  // "123"
console.log(hash[null]); // "123"

var nullValue = null;         //変数の値がnullでもOK
console.log(nullValue);       //null
console.log(hash[nullValue]); //"123"
5
5
8

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
5
5