Google app script learning note — foundamentals

Haifeng Wang
1 min readDec 23, 2020

Variables: Need to know the difference between const, let and var.

Const cannot be reassigned, but the value can change; Let can be reassigned, but cannot redeclare. Var can be reassigned, it has function scope.

Operators: math operators, string operators, comparison operators(always return boolean value).

Need to know the Math library, string operators back tick using to multiline string. comparison operators note strict equal and double equal sign.

Function: there are two formats, one is the basic function, the other is arrow function syntax.

We can either another function in a function, or assign functions to variables, or pass functions as arguments to other functions. And know how to use default parameters.

Arrays: Add to end use “push”, add to start of array use “unshift”, add to middle of array use “spice”; remove from end use “pop”, remove from beginning use “shift”, remove from the middle use “spice”;

Objects: 1) create an object with cruly brackets, key/value pairs, ordering in not important. Use dot notation or square bracket notation to get values or add values or update values. use delete command to delete an item from an object.

Loops: use “for” , “forEach”, and use “map” arry method to create a new array from the existing. Can’t use forEach method on objects, can use for to loop over objects, get its value use bracket notation.

--

--