Skip to content

Instantly share code, notes, and snippets.

@ramazankanbur
Created May 17, 2020 19:42
Show Gist options
  • Save ramazankanbur/f5403e8041be78a911446f13e30d3d29 to your computer and use it in GitHub Desktop.
Save ramazankanbur/f5403e8041be78a911446f13e30d3d29 to your computer and use it in GitHub Desktop.
var symKey = Symbol();
var obj = {
[symKey]: 'symbol val',
a: 'val1',
b: 'val2',
};
console.log(obj);
//{ a: 'val1', b: 'val2', [Symbol()]: 'symbol val' }
console.log(obj[symKey]);
//symbol val
//referans ile güncellenebilir
obj[symKey] = 'symbol val updated';
console.log(obj);
//{ a: 'val1', b: 'val2', [Symbol()]: 'symbol val updated' }
//Object.keys() ile obj'nin symbol tipli özelliklerine erişilmez
console.log(Object.keys(obj));
//[a,b]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment