Skip to content
This repository has been archived by the owner on Dec 28, 2022. It is now read-only.

Latest commit

 

History

History
45 lines (38 loc) · 2.11 KB

17-June-2018.md

File metadata and controls

45 lines (38 loc) · 2.11 KB

TODO

  1. Go through https://javascript.info/ and JS stuff I might not already know.

Small stuff

  • special numeric types infinity,-infinity,NaN
  • typeof null as object is a known js bug
  • let n = Number("8"); let n = +"8"; let ch = String(8)
  • a = b = c = 3; assignemnt operator returns value of assigned variable
  • comma operator
let a = (1 + 2, 3 + 4)
alert( a ); // 7 (the result of 3 + 4)
  • let age = prompt('How old are you?', 100); //default input value 100
  • let isBoss = confirm("Are you the boss?"); // OK or CANCEL
  • || operator evaluates from left to rigth and RETURNS first truthy value encountered or the last operand value of false.
let currentUser = null;
let defaultUser = "John";
let name = currentUser || defaultUser || "unnamed";
alert( name ); // selects "John" – the first truthy value
alert( undefined || null || 0 ); // 0 (all falsy, returns the last value)
  • & operator evaluates left to right and RETURNS first falsy value or the last operand value if all true.
  • The directive continue helps to decrease nesting level

Good stuff

  • In JS object names are references to a memory loacation ie objects are assigned by reference. let a = { name : "pran" }; let b = a; b.name = "aya"; console.log(a.name)

    CLONING

    To make a copy of object use js let newObj = Object.assign(destObj,srcObc1,srcObj2,srcObj3) will copy the properties of srcObj's to destObj and return the destObj. Eg. to clone an object 'User', let cloneUser = Object.assign({},User)

    DEEP CLONING

    If source object has properties of type Object eg let person = { name : "pranaya", address : { street : "a", flat : "b" }} then the property street will copied as a reference. To solve this we will need to check if prop of source object is of type Object and then use Object.assign for it. OR use lodash library function called _.cloneDeep(obj).

  • Garbage collection

  1. Do first 15 excercies of https://github.com/chris-void/pyway/blob/master/Learn%20Python%20The%20Hard%20Way%2C%203rd%20Edition%20.pdf
  2. Make changes to SC**T API
  3. Go through React Native docs