JavaScript Autoboxing: Primitive String Value

Quick JS Brain Teaser: What happens when you try to add a property to a primitive string value? let str = "hello"; str.customProp = "world"; console.log(str.customProp); Options: A) "world" B) undefined C) TypeError D) "helloworld" Does this match your expectations? Drop your answer in the comments and explain the autoboxing behavior! Let's discuss how JavaScript handles primitives vs objects. #JavaScript #JavaScriptInterviewQuestion #JavaScriptFundamentals

To view or add a comment, sign in

Explore content categories