Question #47

Author: admin
tags: JavaScript  
'use strict';

const obj = {
  0x1: 100,
  '0x1': 200,
  '1': 300,
  1: 400,
}

console.log(Object.keys(obj).length); // ??
How many properties are there in an object? What will the console output?
Hint: 0x1 is a hexadecimal notation of the decimal number 1.
1
2
3
4
Nothing. There is an error in the code.
Object property names can only be of type string or type symbol.
All "numeric" property names in objects are actually strings; all numbers are automatically converted to strings.
Prior to ES6, strict mode prohibited duplication of property names, but since ES6 this duplication in the object literal is allowed, so each duplicate entry overwrites the value of the previous entry.
Rate the difficulty of the question:
easyhard