This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var foo = { | |
[Symbol()]: 'foo', | |
[Symbol('foo')]: 'bar', | |
[Symbol.for('bar')]: 'baz', | |
propriedade: 'legal' | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
console.log(Symbol.keyFor(Symbol.iterator)) // undefined |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let iframe = document.createElement(iframe) | |
iframe.src = 'https://google.com' | |
document.body.appendChild(iframe) | |
console.log(Symbol.iterator === iframe.contentWindow.Symbol.iterator) // True |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let texto = '/foo/' | |
let conversao = /foo/.toString() | |
console.log(texto.startsWith(conversao)) // True |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let texto = '/regex/' | |
let literal = /regex/ | |
literal[Symbol.match] = false | |
console.log(text.startsWith(literal)) // True |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let iframe = document.createElement('iframe') | |
iframe.src = 'https://google.com' | |
document.body.appendChild(iframe) | |
console.log(Symbol.for('chave') === iframe.contentWindow.Symbol.for('chave')) // True |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const s1 = Symbol.for('chave') // Symbol ainda não existe, então ele é criado e retornado | |
const s2 = Symbol.for('chave') // Symbol já existe então ele é retornado | |
console.log(Symbol.keyFor(s1)) // Chave | |
console.log(Symbol.keyFor(s2)) // Chave |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const s1 = Symbol.for('chave') // Symbol ainda não existe, então ele é criado e retornado | |
const s2 = Symbol.for('chave') // Symbol já existe então ele é retornado | |
// Ao compararmos | |
console.log(s1 === s2) // True |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
console.log(Symbol() === Symbol()) // False | |
console.log(Symbol('abc') === Symbol('abc')) // False |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let misterio = Symbol('Uma descrição deste Symbol') |