Skip to content

Instantly share code, notes, and snippets.

View mohanramphp's full-sized avatar

Mohan Ram mohanramphp

View GitHub Profile
@mohanramphp
mohanramphp / composing-software.md
Created July 5, 2019 05:29 — forked from rosario/composing-software.md
Eric Elliott's Composing Software Series
@mohanramphp
mohanramphp / fibonacci-generator.js
Created July 20, 2018 08:17 — forked from jfairbank/fibonacci-generator.js
Fibonacci ES6 Generator
function *fibonacci(n) {
const infinite = !n && n !== 0;
let current = 0;
let next = 1;
while (infinite || n--) {
yield current;
[current, next] = [next, current + next];
}
}
@mohanramphp
mohanramphp / screening.js
Created July 20, 2018 07:54 — forked from jgornick/screening.js
JS: Interview Questions
// 1: how could you rewrite the following to make it shorter?
if (foo) {
bar.doSomething(el);
} else {
bar.doSomethingElse(el);
}
Answer:
bar[foo ? 'doSomething' : 'doSomethingElse'](el);
@mohanramphp
mohanramphp / modern_js.md
Created July 14, 2018 11:14 — forked from gaearon/modern_js.md
Modern JavaScript in React Documentation

If you haven’t worked with JavaScript in the last few years, these three points should give you enough knowledge to feel comfortable reading the React documentation:

  • We define variables with let and const statements. For the purposes of the React documentation, you can consider them equivalent to var.
  • We use the class keyword to define JavaScript classes. There are two things worth remembering about them. Firstly, unlike with objects, you don't need to put commas between class method definitions. Secondly, unlike many other languages with classes, in JavaScript the value of this in a method [depends on how it is called](https://developer.mozilla.org/en-US/docs/Web/Jav