• How to work a Window
  • What is dom
  • What is dom rendering
  • Global scope vs local scope
  • This vs self
  • What is prototype
  • Chrome developer tools
  • Async io and nonblocking io
  • Single thread
  • Function and object
  • Typescript
  • Design pattern
  • jQuery best practice or jQuery best performance
  • Package npm, yarn
  • Task runner gulp, grant
  • Modularizing tools browserify, webpack
  • Todo MVC

Then you can decide angular or react

What is dom?

The Document Object Model (DOM) is a programming API for HTML and XML documents that represent a web page. A web page is made of elements, or nodes, such as the html element, the body element, and paragraph elements. The DOM builds a tree-like structure of these nodes in a hierarchy where some nodes are parents, and other nodes are children, like this:

<html> (root node)
	<head> (child of the root node)
		<title></title> (child of the head)

The DOM provides an API for querying the tree and accessing objects based on their tag names, id, class names, or their relationship to other nodes in the tree. It also provides methods for adding and removing nodes, moving them to different locations in the tree, or modifying their contents.
The DOM is a bridge of HTML and JavaScript


The document is just the web page

Objects are elements

Every HTML element in the document is an object

<head></head> is an object
<body></body> is an object
<ul></ul> is an object
<p></p> is an object 

When it is created?

When a web page is loaded, the browser creates a DOM structure, that is nothing but object tree structure.

How you can use the document object?

	-> Finding HTML Elements
	-> Changing HTML Elements
		element.innerHTML =  new html content
	-> Adding and Deleting Elements

Primitive data types in javascript

	4, 9.3, -10
	"Hello world", "45"
	true or false

How to display best selling products in magento

1. Create a new file for Block:

 * Catalog Product Bestseller Block
 * @author Amasty Team
class Mage_Catalog_Block_Product_Bestseller extends Mage_Catalog_Block_Product_Abstract
    public function getCollection()
        $storeId = Mage::app()->getStore()->getId();
        $collection = Mage::getResourceModel('reports/product_collection')
            ->setOrder('ordered_qty', 'desc');
        if (Mage::helper('catalog/product_flat')->isEnabled()) {
                ->joinInner(array('e2' => 'catalog_product_flat_' . $storeId), 'e2.entity_id = e.entity_id');
        } else {
                ->addAttributeToSelect(array('name', 'price', 'small_image'));
        if ($categoryId = $this->getCategory()) {
            $category = Mage::getModel('catalog/category')->load($categoryId);
        $collection->setPage(1, $this->getLimit());
        return $collection;

2. Create a template file 

 * Bestseller Products block template
 * @see Mage_Catalog_Block_Product_Bestseller
<div class="block block-list block-viewed">
    <div class="block-title">
        <strong><span><?php echo $this->__($this->getHeader()) ?></span></strong>
    <div class="block-content">
        <?php $products = $this->getCollection(); ?>
        <?php if (0 < $products->getSize()) { ?>
            <table class="bestseller-table">
                    <?php foreach ($products as $p) { ?>
                        <td style="padding: 15px 15px 0px 15px;">
                            <a href="<?php echo $p->getProductUrl() ?>" title="<?php echo $this->htmlEscape($p->getName()) ?>" class="product-image">
                                <img src="<?php echo $this->helper('catalog/image')->init($p, 'small_image')->resize(125) ?>" width="125" height="125" alt="<?php echo $this->htmlEscape($p->getName()) ?>" />
                            <h3 class="product-name">
                                <a href="<?php echo $p->getProductUrl() ?>" title="<?php echo $this->htmlEscape($p->getName())?>">
                                    <?php echo $this->htmlEscape($p->getName()) ?>
                            <?php echo $this->getPriceHtml($p, true) ?>
                    <?php } ?>
                    <?php foreach ($products as $p) { ?>
                    <td style="padding: 0px 15px 15px;">
                        <?php if($p->isSaleable()): ?>
                            <button type="button" title="<?php echo $this->__('Add to Cart') ?>" class="button btn-cart" onclick="setLocation('<?php echo $this->getAddToCartUrl($p) ?>')">
                                <span><span><?php echo $this->__('Add to Cart') ?></span></span>
                        <?php else: ?>
                            <p class="availability out-of-stock"><span><?php echo $this->__('Out of stock') ?></span></p>
                        <?php endif; ?>
                    <?php } ?>
        <?php } ?>

3. Now you need to call the created block, to do that go to Backend > CMS > Pages > Edit Page ‘Home page’ and add the following lines of code:

{{block type="catalog/product_bestseller" template="catalog/product/bestseller.phtml" header="Bestsellers" limit=4}}

4. You need to create a permission for this block:
   Backend – > System – > Permissions – > Blocks – > 'Add New Block' button