loading...

re: Use $ & $$ Instead of document.querySelector/All in JavaScript without jQuery VIEW POST

FULL DISCUSSION
 

This looks cool.

with you example could you still do this though?

const username = 'johndoe'
const age = 32

console.log(`The name of the user is ${username} and his age is ${age}.`)

 

now that I think about it, I guess this would be a scope issue

 

Yep, it would look like this:

const username = 'johndoe'
const age = 32

console.log(`The name of the user is ${username} and his age is ${age}.`)
console.log(`Element is: ${$('#article-reaction-actions')}.`)

The outer $ in the template string will start the evaluation. the $ inside of ${} will refer to the global $.

Hope this clears it up!

Code of Conduct Report abuse