What is the difference between javascript property and javascript variable?
javascript, object, properties
Solution
`=` is for object property or global/local variable assignment. `:` is only for property assignment at object definition.
Also: You can `delete` a property. You cannot `delete` a variable.
var obj = {
p1: 'im p1',
p2: 2
};
obj.p1 = 'im updated p1'; // assign a new value to object property
var v = 'just a var'; // is global outside a function and local inside a function
delete obj.p1; // is ok
delete v; // is not ok
Problem
While assigning values in javascript I came across this ``` var obj = { resultCodeId: data[i].resultCodes[j].resultCodeId }; var resultCodeId= data[i].resultCodes[j].resultCodeId; ``` How do ':' and '=' fundamentally differ in javascript ?Can variable also have properties or just objects in javascript have properties?