$ e $$ are now browsers' native functions?

9

When using the console on a page without JavaScript, I noticed that typing $ had the same effect as document.querySelector and typing $$ had the same effect as document.querySelectorAll .

Would two functions shortcuts to the querySelector or do they have any specific behavior different?

What's their name? I even searched the caniuse link, but I did not get results (I tried "dollar" too)

    
asked by anonymous 24.04.2017 / 23:07

1 answer

9

These are console-only methods, shortcuts to facilitate the programmer.

This is confirmed by Chrome documentation here and Edge documentation here where it says:

  

$ () is a shortcut to document.querySelector ().
$$ () is a shortcut to document.querySelectorAll (). $ 0 , $ 1 , $ 2 , $ 3 , $ 4 returns the last elements selected by DOM explorer (elements)

There is still $_ but it behaves differently in Chrome and Edge:

Edge:

  

$ _ () is a shortcut to the last object / element.

Chrome:

  

$ _ is a shortcut to show the value of the last evaluated expression.

    
25.04.2017 / 05:40