Saturday, July 2, 2016

JavaScript Array developer.Mozilla.org - 3+ hours study

July 2, 2016

First thing in the morning, read JavaScript Array webpage, and then, start to work on the target:

1. Memorize all the content on the page.  (Estimated time to understand every term on the page: 10+ hours)

https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Array/prototype

2. List all concepts to learn
3. Questions about the content

Training on JavaScript - start from memorizing JavaScript Array APIs

Time spent:
3 hours (July 2, 2016)

https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Array/prototype

Design drills to memorize the JavaScript function names:

1. Properties

Array.prototype
Array.length

Method   (33 methods)

Array.from()
Array.isArray()
Array.of()

Array.prototype.concat()
Array.prototype.copyWithin()
Array.prototype.entries()
Array.prototype.every()
Array.prototype.fill()

Array.prototype.filter()
Array.prototype.find()
Array.prototype.findIndex()
Array.prototype.forEach()
Array.prototype.includes()

Array.prototype.indexOf()
Array.prototype.join()
Array.prototype.keys()
Array.prototype.lastIndexOf()
Array.prototype.map()

Array.prototype.pop()
Array.prototype.push()
Array.prototype.reduce()
Array.prototype.reduceRight()
Array.prototype.reverse()

Array.prototype.shift()
Array.prototype.slice()
Array.prototype.some()
Array.prototype.sort()
Array.prototype.splice()

Array.prototype.toLocaleString()
Array.prototype.toSource()
Array.prototype.toString()
Array.prototype.unshift()
Array.prototype.values()

Inheritance:

Function -> properties ->   (5, please remember: c, d, l, n, p)
Functon.caller
Function.displayName
Function.length
Function.name
Function.prototype

Function -> Methods -> (6, please remember: a, b, c, i, t, t)
Function.prototype.apply()
Function.prototype.bind()
Function.prototype.call()
Function.prototype.isGenerator()
Function.prototype.toSource()
Function.prototype.toString()

Object

Methods

Object.prototype.__defineGetter__()
...

2. Study notes (July 2, 2016):

a global object,
list-like objects
Access(index into) an Array item
Loop over an array - forEach
push - Add to the end of an Array
pop  -  Remove from the end of an Array
shift - Remove from the front of an Array
unshift - Add to the front of an array
     Adds one or more elements to the front of an array and returns the new length of the array.
push - find the index of an item in the Array
pop  - Remove an item by Index Position
splice - Remove an item by Index Position
slice  - Copy an Array
    julia's comment: slice or dice, slice is just to get part of array, can be the whole array. 
           function syntax, startIndex, endIndex, arr.slice([begin[, end]])
from - Array.from(), creates a new Array instance from an array-like or iterable object. 
isArray - Array.isArray(), returns true if a variable is an array, if not false. 
of  - Array.of(), creates a new Array instance within a variable number of arguments, regardless of number or type of the arguments. 

Mutator methods - modify the array
copyWithin - Copies a sequence of array elements with the array
fill - Fills all the elements of an array from a start index to an end index with a static value.

splice - Adds and/or removes elements from an array.
join - joins all elements of an array into a string.

Iteration methods:
forEach()
entries()
every()
some()
filter()
find()
findIndex()
keys()
map()
reduce()
reduceRight()
values()

Question: Syntax - what kind of definition? [ <- optional argument?

traversal and mutation operations 
Arrays can be stored at non-contiguous locations in the array, JavaScript arrays are not guaranteed to be dense.
Questions: When to use typed arrays? 
   JavaScript arrays are not guaranteed to be dense, so typed arrays are guaranteed to be dense. (? Look into it later)

Questions: an associated array - what is "associated" meaning? 

zero-indexed
using bracket notation - renderer['ed].setTexture(model, 'character.png')  - works properly
with dot notation - cannot be referenced with dot notation, must be accessed using bracket notation. 

Array.length talk -     A JavaScript array's length property and numerical properties are connected. Several of the built-in array methods (e.g., join, slice, indexOf, etc.) take into account value of an array's length property when they are called. Other methods (e.g., push, splice, etc.) also result in updates to an array's length property. 
  Questions: built-in array methods ? Array.prototype.join, those functions are defined for all iterable object. 

Good reading with one example, two lines of JavaScript code: 
Creating an array using the result of a match
RegExp.exec, String.match, and String.replace (? study later)

Memorize this example - one regular express a time

// Match one d followed by one or more b's followed by one d
// Remember matched b's and the following d
// Ignore case

var myRe = /d(b+)(d)/i; 
var myArray = myRe.exec('cdbBdbsbz')

Question: review regular expression in JavaScript?

Array instances 
All array instances inherit from Array.prototype. 



No comments:

Post a Comment