Does the value have a length attribute?

I typed 78.length directly into the browser console and entered enter to report an error, but

var someValue = 78;
var strLength = someValue.length;
console.log(strLength);

this does not report an error, but only outputs undefined,. Why?

Apr.07,2021

everything is an object. The Number type inherits from Number.prototype,Number.prototype and inherits from Object.prototype, so if you get the length attribute of number value, you will look for it on Number.prototype and Object.prototype, but cannot return undefined

.

so why does 78.length report an error? Let's talk about the mechanism of . . In js, . immediately after the integer will be understood as a decimal point, so 78.length will not report an error, then 78.0.length will not report an error, 78..length will not report an error, (78) .length will not report an error, and saving the value in a variable to access the attribute will not report an error.


clipboard.png


Number type has no length attribute. You can refer to MDN document Number type description


without length attribute

.
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e458a6-44b45.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e458a6-44b45.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?