index
Javascript Index#
- string, number, boolean, array, object, null, undefined
DOM Event#
- event capturing, Target phase, event bubbling, event delegation- event.target, event.target.value, event.target.closest, e.target.className, e.target.id, e.target.innerHTML- event.stopPropagation, event.stopImmediatePropagation, event.preventDefault(),- elem.addEventListener(..., true)- onchange, onclick, onmouseover, onload, onkeydown- Abortcontroller and symbol; cancelling the api request
- Throttling and debouncing
- asynchronous programming, callback and promises, callback hell, error callback
- closure, hoisting
- function, arguments.length, anonymous function, IIFE (use of it in singleton in vanilla js);
- lexical, functional and block scope
- event queue, event-loop, call stack, single threaded, macro-tasks(apicalls, setTimeout, mouse-event, script tag), micro-tasks(process.nextTick, promises - higher priority),
- type=module in script tag (import/export, deferred execution, module scoped variables)
- call, bind, apply (how .apply is used when num of arguments passed is
uncertain and you have to write a wrapper function)
func.apply(this, [...args, callback]);
- method chaining, currying,
- generators, yield
Typescript#
- static type checking at compile time
- TypeScript decorators are functions that can be used to modify or add metadata to classes, methods, or properties.
- Generics interface e.g interface
myInterface<T> - readonly : The readonly modifier can be used to create arrays that cannot be modified after initialization.
const arr: readonly number[] = [1, 2, 3]arr.push(4) // throws errorarr[1] = 6 // throws errorconsole.log(arr[0]) // prints 1
const obj: { readonly [key: string]: any } = { a: 1, b: 2 }obj.a = 1 // throws error- keyof : obtain the union type of all possible property names of a given type.
type Person = { name: string age: number address: string}
type PersonKey = keyof Person // "name" | "age" | "address"- Declaration files (.d.ts) provide type information for existing JavaScript code, allowing TypeScript to understand the types used in external libraries. Definition files are typically generated by tools like DefinitelyTyped.
- Enums, and what are "const enums"
enum Color { Red, Green, Blue}let color: Color = Color.Green- "strict mode" in TypeScript : ncludes options like strictNullChecks, strictFunctionTypes
- "conditional imports" in TypeScript
if (condition) { import("moduleA").then((moduleA) => { // Use moduleA })}Document methods#
- document.querySelector(".className"),- document.querySelector("#idName"),- document.getElementById('id_name'),- document.getElementsByClassName('className')- document.cookieEcmascript- ES5(2009) - useStrict, JSON.stringify, JSON.parse,
- ES6(2015) - Promises, let, const, template literal, arrow function (self = this), class, super(),constructor,extends, rest and spread. default param, destructuring,generators (function*)
- ES7(2017) - async await and equivalent promise conversion
Object- Object.keys, Object.values, for(const of )
- Object.freeze(), Object.seal(), Object.isFrozen(), Object.isSeal()
- Object.prototype.hasOwnProperty
- Object.create()
- Prototype, constructor, proto, Object.create(), prototype.constructor (function constructor), instanceof
- object.hasOwnProperty(property)
Array- arr.sort((a,b)=> a-b);
- array.filter().map().join("")
Promise#
- promise.all(), promise.race(), .resolve(), .reject(), callback- state of promise : pending, fulfilled, rejected- new Promise((reolve, reject)=> {})- Difference between myPromise.then(result => {}, err => {}) and myPromise.then(result => {}).catch(err => {});- ways of creating an object in JS
- data types in JS - string, number, boolean, object, array, null, undefined
string.reverse().split("").includes().trim()- AJax calls :
XMLHttpRequestandfetch API(modern version) - higher order functions (e.g map, filter, foreach etc.)
- JSONP (JSON with Padding) - hack for handling cors issue
- Host objects(provided by browser or run time env like node.js) vs native objects (provided by language)
- Debugging
- chrome devtools
- debugger statement
- console.log
- CommonJS abd Asynchronous Module Definition (AMD)
DOMContentLoadedandloadeventUA string(user agent string)Feature Detection