Eric Santos’ Post

Tell me about JavaScript 𝗽𝗿𝗶𝗺𝗶𝘁𝗶𝘃𝗲 𝘁𝘆𝗽𝗲𝘀: In JavaScript there are 7 primitive types: 𝗻𝘂𝗹𝗹, 𝘂𝗻𝗱𝗲𝗳𝗶𝗻𝗲𝗱, 𝘀𝘁𝗿𝗶𝗻𝗴, 𝗻𝘂𝗺𝗯𝗲𝗿, 𝗯𝗼𝗼𝗹𝗲𝗮𝗻, 𝘀𝘆𝗺𝗯𝗼𝗹, 𝗯𝗶𝗴𝗶𝗻𝘁. All primitive types are 𝗶𝗺𝗺𝘂𝘁𝗮𝗯𝗹𝗲, that is, they cannot be altered. They don't have methods, but they behave like they do. When properties are accessed on primitives, JavaScript 𝗮𝘂𝘁𝗼-𝗯𝗼𝘅𝗲𝘀 the value into a wrapper object. It makes possible to run some operations over the value, like 𝘁𝗼𝗙𝗶𝘅𝗲𝗱 in Number or 𝗰𝗵𝗮𝗿𝘁𝗔𝘁 in String. The object is discarded right after the operation completes. When passing a primitive value to a 𝗳𝘂𝗻𝗰𝘁𝗶𝗼𝗻, a copy of the value will be passed. This means that the original value and the value passed through the function have different space in memory. Use the comments if you have some addition or a simpler way to explain this. #javascript #techinterview #jobinterview #question #interviewquestion

  • graphical user interface, text, application

... Primitives are allocated on stack.

To view or add a comment, sign in

Explore content categories