Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>JS Bin</title>
</head>
<body>
</body>
</html>
 
// declare an object using const
const myObject = {a: 1, b: 2, c: 3}
/*
add update an existing property
and add a new property to myObject
and no error will occur, because
we did not "reassign" new values
directly to the myObject variable using `=`
*/
myObject.c = 30
myObject.d = 4
console.log(myObject) // { a: 1, b: 2, c: 30, d: 4}
/*
However, uncomment the line below and observe
the error when we attempt to "reassign" values
directly to myObject
*/
// myObject = {e: 5, g: 6} // an error will occur
Output

You can jump to the latest bin by adding /latest to your URL

Dismiss x