Skip to content

Instantly share code, notes, and snippets.

@SriniTechHub
SriniTechHub / countriesAddressPostal.js
Created July 8, 2020 08:22 — forked from ShreyKumar/countriesAddressPostal.js
List of countries and their respective postal codes with ranges (July 2020)
// Country list source: https://www.dhl.com/en/country_profile.html#.XwODEJNKjOQ
// Country abbreviation source: https://planetarynames.wr.usgs.gov/Abbreviations
// Postal code: https://gist.githubusercontent.com/jamesbar2/1c677c22df8f21e869cca7e439fc3f5b/raw/21662445653ac861f8ab81caa8cfaee3185aed15/postal-codes.json
// Postal code: https://en.wikipedia.org/wiki/List_of_postal_codes
// Country/territory items with no postal code regexes or ranges either do not require postal codes
// or there may not be enough information for that country/territory
export const COUNTRY_ADDRESS_POSTALS = [{
abbrev: 'AF',
@SriniTechHub
SriniTechHub / performanceTips2.js
Created July 22, 2020 04:26 — forked from gmilby/performanceTips2.js
more performance tips for jquery
1. Define local variables
When a variable is referenced, Javascript hunts it down by looping through the different members of the scope chain. This scope chain is the set of variables available within the current scope, and across all major browsers it has at least two items: a set of local variables and a set of global variables.
Simply put, the deeper the engine has to dig into this scope chain, the longer the operation will take. It first goes through the local variables starting with this, the function arguments, then any locally defined variables, and afterwards iterates through any global variables.
Since local variables are first in this chain, they’re always faster than globals. So anytime you use a global variable more than once you should redefine it locally, for instance change:
var blah = document.getElementById('myID'),
blah2 = document.getElementById('myID2');
to:
var doc = document,
blah = doc.getElementById('myID'),
blah2 = doc.getElementById('myID2');
/*
JavaScript: Learn JavaScript in Y Minutes
Reference URL: https: //learnxinyminutes.com/docs/javascript/
JavaScript was created by Netscape’s Brendan Eich in 1995. It was originally intended as a
simpler scripting language for websites, complementing the use of Java for more complex web
applications, but its tight integration with Web pages and built-in support in browsers has
caused it to become far more common than Java in web frontends.
@SriniTechHub
SriniTechHub / javascript_learning.md
Created July 22, 2020 04:37 — forked from priya-jain-dev/javascript_learning.md
My learning from all online source at one place.

What is Event Propagation?

When an event occurs on a DOM element, that event does not entirely occur on that just one element.

Event Propagation has three phases.

Capturing Phase – the event starts from window then goes down to every element until it reaches the target element. Target Phase – the event has reached the target element. Bubbling Phase – the event bubbles up from the target element then goes up every element until it reaches the window. The addEventListener method has a third optional parameter useCapture with a default value of false the event will occur in the Bubbling phase if true the event will occur in the Capturing Phase.

@SriniTechHub
SriniTechHub / ch3.md
Created July 22, 2020 04:52 — forked from kad3nce/ch3.md
# You Don't Know JS: ES6 & Beyond

You Don't Know JS: ES6 & Beyond

Chapter 3: Organization

Some of the most important changes in ES6 involve improved support for the patterns we already commonly use to organize JavaScript functionality. This chapter will explore Iterators, Generators, Modules, and Classes.

Iterators

An iterator is a structured pattern for pulling information from a source in one-at-a-time fashion. This pattern has been around programming for a long time. And to be sure, JS developers have been ad hoc designing and implementing iterators in JS programs since before anyone can remember, so it's not at all a new topic.

What ES6 has done is introduce an implicit standardized interface for iterators. Many of the built in data structures in JavaScript will now expose an iterator implementing this standard. And you can also construct your own iterators adhering to the same standard, for maximal interoperability.

Advanced Modern JavaScript Guide

Table of Contents

Guide Overview


Keywords and Operations

@SriniTechHub
SriniTechHub / ch5.md
Created July 22, 2020 05:19 — forked from kad3nce/ch5.md
# You Don't Know JS: Scope & Closures

You Don't Know JS: Scope & Closures

Chapter 5: Scope Closure

We arrive at this point with hopefully a very healthy, solid understanding of how scope works.

We turn our attention to an incredibly important, but persistently elusive, almost mythological, part of the language: closure. If you have followed our discussion of lexical scope thus far, the payoff is that closure is going to be, largely, anti-climatic, almost self-obvious. There's a man behind the wizard's curtain, and we're about to see him. No, his name is not Crockford!

If however you have nagging questions about lexical scope, now would be a good time to go back and review Chapter 2 before proceeding.

Enlightenment

@SriniTechHub
SriniTechHub / ch6.md
Created July 22, 2020 05:19 — forked from kad3nce/ch6.md
# You Don't Know JS: *this* & Object Prototypes

You Don't Know JS: this & Object Prototypes

Chapter 6: Behavior Delegation

In Chapters 4 and 5, we addressed the [[Prototype]] mechanism in detail, and why it's confusing and inappropriate (despite countless attempts for nearly two decades) to label it "class" or "inheritance". We trudged through not only the fairly verbose syntax (.prototype littering the code), but the various gotchas (like surprising .constructor resolution or ugly pseudo-polymorphic syntax). We explored variations of the "mixin" approach, which many people use to attempt to smoothe over such rough areas.

It's a common reaction at this point to wonder why it has to be so complex to do something seemingly so simple. Now that we've pulled back the curtain and seen just how dirty it all gets, it's not a surprise that most JS developers never dive this deep, and instead relegate such mess to a "class" library to handle it for them.

I hope if you're reading these "You Don't Know JS" books, you're not content to just gloss ov