JSFiddle - React, Tailwind, and code Playground

by spechackers

JavaScript

function vinoth(){}
vinoth.designation = "programmer";
console.log(vinoth.designation); // prints out programmer

var vinoth = "employee";
vinoth.designation = "programmer"; // does not throw any warnings
console.log(vinoth.designation); //returns undefined

//Behind the scenes
var vinoth = "employee";
//trying to set a property on primitive
(new String(name)).desigination = "programmer"; 
 
console.log(vinoth.designation); //undefined
//another new object created to retrieve property 
(new String(name)).designation;