Skip to content

Instantly share code, notes, and snippets.

View gpalsingh's full-sized avatar
😀
Working on something cool!

Gurkirpal Singh gpalsingh

😀
Working on something cool!
View GitHub Profile
@gpalsingh
gpalsingh / bashrc.example
Created November 28, 2017 18:15
Colored prompt with git branch
# uncomment for a colored prompt, if the terminal has the capability; turned
# off by default to not distract the user: the focus in a terminal window
# should be on the output of commands, not on the prompt
#force_color_prompt=yes
if [ -n "$force_color_prompt" ]; then
if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
# We have color support; assume it's compliant with Ecma-48
# (ISO/IEC-6429). (Lack of such support is extremely rare, and such
# a case would tend to support setf rather than setaf.)
@gpalsingh
gpalsingh / Google ICS: Mobile Web, Course 2 Summary.md
Last active March 8, 2018 11:47
My notes on course on ES6. Not comprehensive.

Lesson 6: Syntax

  • let: Variables can be reassigned, but can’t be redeclared in the same scope.
  • const: Variables must be assigned an initial value, but can’t be redeclared in the same scope, and can’t be reassigned.
  • Hoisting: Before any JavaScript code is executed, all variables are hoisted, which means they're raised to the top of the function scope.
  • Temporal dead zone: If a variable is declared using let or const inside a block of code, then the variable is stuck in what is known as the temporal dead zone until the variable’s declaration is processed.
  • Suggested to ditch var in place of using let and const.
  • Template literals: Denoted with backticks ( `` ), template literals can contain placeholders which are represented using ${expression}.
  • Examples:
@gpalsingh
gpalsingh / add_normal.js
Last active March 3, 2018 06:55
Code examples used to explain arrow functions
var add = function(x, y) {
var total = x + y;
return total;
}
console.log(add(2, 3));
var add = (x, y) => {
var total = x + y;
return total;
}
console.log(add(2, 3));
@gpalsingh
gpalsingh / script.js
Last active March 3, 2018 07:03
add_arrow_one_liner_1
var add = (x, y) => { return x + y; }
console.log(add(2, 3));
@gpalsingh
gpalsingh / add_arrow_one_liner_2.js
Last active March 3, 2018 07:21
add_arrow_one_liner_2
var add = (x, y) => x + y;
console.log(add(2, 3));
@gpalsingh
gpalsingh / arrow_one_argument_1.js
Last active March 3, 2018 07:18
arrow_one_argument_1
var hello = (name) => `Hello ${name}!`
console.log(hello('Gurpal'));
@gpalsingh
gpalsingh / arrow_one_argument_2.js
Created March 3, 2018 07:23
arrow_one_argument_2
var hello = name => `Hello ${name}!`
console.log(hello('Gurpal'));
@gpalsingh
gpalsingh / no_arguments_1.js
Last active March 3, 2018 07:28
no_arguments_1
var hello = => "Hello";
console.log(hello());
@gpalsingh
gpalsingh / no_arguments_2.js
Last active March 3, 2018 07:32
no_arguments_2
var hello = _ => "Hello";
console.log(hello());