One thing i would like to suggest all the beginners is that, try to keep in mind which data type takes how much memory-space while programming. No need to go in-depth but still it is considered a good practice, also you can be asked in the interviews.
While it might not be your everyday task but still it is useful for you in further improvement, when you have to optimize the program for better space-complexity specially working with algorithms.
Firstly, you might have heard about TeraBytes, GigaBytes, MegaBytes and so on, so always refer Bytes instead of Bits when talking about memory-space,because...
just kidding...
Here's a simple breakdown:
//1-Byte = 8-Bits
Number(int, float) -> takes 8-bytes(64-bits)
// does not matter how many digits you enter it's still 8-bytes, unless you enter tooooooo many digits.String("Hello-World") -> takes 2-bytes per character["A","@","7"]
// remember anything written between " ", is considered as set of characters/stringBoolean(true, false) -> 4-Bytes(approx)
BigInt(really, really big number) -> Depends on size.
...there are more, but i think these are enough.
**Readers, I am also a beginner ^_^, so please correct me if I am wrong, and please share your suggestions also. Thank You.
And also i would like to add is that, the information above is for JavaScript, the value may vary depending upon the languages.**
Top comments (0)