---
title: "Native JS Like jQuery"
description: "Lately was pawing at some Selector API’s and really liked the raw power of native JS! So here is some comaprsion of Native."
url: "https://h3manth.com/scribe/native-js-jquery/"
canonical_url: "https://h3manth.com/scribe/native-js-jquery/"
markdown_url: "https://h3manth.com/scribe/blog/native-js-jquery.md"
publishDate: "2012-05-14T00:00:00.000Z"
author: "Hemanth HM"
category: "javascript"
tags: ["javascript","web"]
word_count: 150
reading_time_minutes: 1
x_markdown_tokens: 383
content_signal: "ai-train=yes, search=yes, ai-input=yes"
---

# Native JS Like jQuery

> Lately was pawing at some Selector API’s and really liked the raw power of native JS! So here is some comaprsion of Native.

Lately was pawing at some [Selector API's](http://h3manth.com/content/url-scraping-javascript "Selector APIs") and really liked the raw power of native JS!

So here is some comaprsion of **Native JS vs jQuery selectors**

As jQuery uses "$" as a shortcut for "jQuery", lets defined a naughty $$ for making things much more easier. [ True! I can use "jQuery.noConflict()".]

> As per the standards The dollar sign ($) and the underscore (_) are permitted anywhere in an IdentifierName.

function $$(selector){ return Array.prototype.slice.call(document.querySelectorAll(selector), 0); } 

Native  | jQuery  
---|---  
$$('body').length  
| $('body').length  
  
$$('div').length  
| $('div').length  
  
  
$$('body div').length  
| $('body div').length  
  
$$('div > p').length  
| $('div > p').length  
  
$$('div + p').length  
| $('div + p').length  
  
$$('div ~ p').length  
| $('div ~ p').length  
  
$$('div[class^=exa][class$=mple]').length  
| $('div[class^=exa][class$=mple]').length  
  
$$('div, p, a').length  
| $('div, p, a').length  
  
  
The above is just the starting to it, even though /me has great respect towards jQuery I like to paw more on native js.
