Category: JavaScript

Data Structure Study in JS (Set)

Keywords unordered, unique elements, cannot be repeated, array with no repeated elements, no concept/order Set in ECMA6https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects

Date in IE

It came across to me today that the new Date() worked differently in chrome and other browsers, namely IE and Safari. This is what happened:12345var date = new Date('2017-08-01 00:00');// in chrome =&

Data Structure Study in JS (Stack&Queue)

Keywords LIFO Stack class implementation12345678910111213141516171819202122232425262728293031323334353637383940414243444546function Stack(){ var items = []; // push - add item to the top of

Data Structure Study in JS (Array)

Keywords simplest memory DS, same data type, modified objects Creating and Initializing1) use new keyword1var testArray = new Array(); 2) []12var testArray = []; //declarevar testArray2 = ['t

How to use Class in JS (2)

Refence to this page. Credits go to Isaaks, the writer of that article. This is for my personal study. Boxing with Prototype & static methodsBoxing: wrapping primitive non-object with a correspond

How to use Class in JS (1)

(This is my personal practice on this page. May use some similar codes.) Declare a class123456class Page { constructor(words, lines){ this.words = words; this.lines = lines; }&#

Deep Copy in JS

When an object is put into another variable, it is copied by reference. This means if the original object changes, the referenced values will change too. 123456789101112131415var originalArr = [ &#

Clousure in JS

This is a brief explanation for closure in js. Closure is a function that returns a function. Basic Usage:12345678910var saveFn = function (val) { return function () { return val