What is the difference between javascript property and javascript variable?

RahulB

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?

jenson-button-event

= 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

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

What is the difference between ">>>" and ">>" in JavaScript?

From Dev

What is the difference between a property and a variable in Swift?

From Java

What is the difference between JavaScript and ECMAScript?

From Dev

What is the difference between JavaScript and jQuery?

From Dev

What is the difference between $ , this and $(this) in javascript fundamentals?

From Dev

What is the difference between the javascript errors "Cannot read property 'foo' of null" and "null is not an object"

From Dev

What is the difference between giving character with quotes as key and just character as key of property of an object in javascript

From Dev

Difference between javascript variable with var and without var?

From Dev

Difference between !condition and variable != otherVariable in Javascript/Jquery?

From Dev

Undefined variable in Javascript: difference between typeof and not exists

From Dev

Javascript - What is the difference between these constructor functions?

From Dev

what is the difference between `offsetLeft` and 'clientLeft' in javascript

From Dev

What is the difference between `this` and `prototype`? javascript oop

From Dev

what is the difference between PHP regex and javascript regex

From Dev

What is the difference between these two functions in Javascript?

From Dev

What is the difference between a dictionary and a Map in Javascript 6?

From Dev

What is the difference between Number() and ToNumber() in javascript?

From Java

What is the difference between JavaScript promises and async await?

From Java

what is the difference between const and const {} in javascript

From Java

What is the difference between ( for... in ) and ( for... of ) statements in JavaScript?

From Java

What is the difference between null and undefined in JavaScript?

From Dev

What is the difference between anonymous and inline functions in JavaScript?

From Dev

What is the difference between JavaScript object and primitive types?

From Dev

What is the difference between "defined" and defined in javascript?

From Dev

What is the difference between 'remove' and 'removeChild' method in javascript?

From Dev

What is the difference between javascript Promise and q promise

From Dev

What is the difference between class and classname in javascript?

From Dev

What's the difference between these two statements in Javascript?

From Dev

Javascript: What is the difference between Function and Class

Related Related

  1. 1

    What is the difference between ">>>" and ">>" in JavaScript?

  2. 2

    What is the difference between a property and a variable in Swift?

  3. 3

    What is the difference between JavaScript and ECMAScript?

  4. 4

    What is the difference between JavaScript and jQuery?

  5. 5

    What is the difference between $ , this and $(this) in javascript fundamentals?

  6. 6

    What is the difference between the javascript errors "Cannot read property 'foo' of null" and "null is not an object"

  7. 7

    What is the difference between giving character with quotes as key and just character as key of property of an object in javascript

  8. 8

    Difference between javascript variable with var and without var?

  9. 9

    Difference between !condition and variable != otherVariable in Javascript/Jquery?

  10. 10

    Undefined variable in Javascript: difference between typeof and not exists

  11. 11

    Javascript - What is the difference between these constructor functions?

  12. 12

    what is the difference between `offsetLeft` and 'clientLeft' in javascript

  13. 13

    What is the difference between `this` and `prototype`? javascript oop

  14. 14

    what is the difference between PHP regex and javascript regex

  15. 15

    What is the difference between these two functions in Javascript?

  16. 16

    What is the difference between a dictionary and a Map in Javascript 6?

  17. 17

    What is the difference between Number() and ToNumber() in javascript?

  18. 18

    What is the difference between JavaScript promises and async await?

  19. 19

    what is the difference between const and const {} in javascript

  20. 20

    What is the difference between ( for... in ) and ( for... of ) statements in JavaScript?

  21. 21

    What is the difference between null and undefined in JavaScript?

  22. 22

    What is the difference between anonymous and inline functions in JavaScript?

  23. 23

    What is the difference between JavaScript object and primitive types?

  24. 24

    What is the difference between "defined" and defined in javascript?

  25. 25

    What is the difference between 'remove' and 'removeChild' method in javascript?

  26. 26

    What is the difference between javascript Promise and q promise

  27. 27

    What is the difference between class and classname in javascript?

  28. 28

    What's the difference between these two statements in Javascript?

  29. 29

    Javascript: What is the difference between Function and Class

HotTag

Archive