This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | var array = [11,2,3,4,5]; | |
| var isGreaterThanTen = array.every(function(item, index, array) { | |
| let isLastIndex = index === array.length - 1; | |
| if(isLastIndex === false) { | |
| array[index + 1] += 10; | |
| } | |
| return item > 10; | |
| }); | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | var arr = [false, false, true, true]; | |
| var hasTrue = arr.some((item, index, arr) => { | |
| arr.pop(); | |
| return item; | |
| }); | |
| console.log(hasTrue); // false | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | var arr = [false, false, true, true]; | |
| var hasTrue = arr.some((item, index, arr) => { | |
| arr.pop(); | |
| return item; | |
| }); | |
| console.log(hasTrue); // false | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | var arr = [false,false]; | |
| let hasTrue = arr.some((item, index, arr) => { | |
| arr.push(true); | |
| return item; | |
| }); | |
| console.log(hasTrue); // false | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | var array = [false, false,false]; | |
| var hasTrue = array.some( function(item, index, array) { | |
| let isLastIndex = index === array.length - 1; | |
| if(isLastIndex === false) { | |
| array[index + 1] = true; | |
| } | |
| return item; | |
| }); | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | class Stack { | |
| constructor(){ | |
| this.data = []; | |
| this.top = 0; | |
| } | |
| push(element) { | |
| this.data[this.top] = element; | |
| this.top = this.top + 1; | |
| } | |
| length() { | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | class Queue { | |
| constructor(){ | |
| this.data = []; | |
| this.rear = 0; | |
| this.size = 10; | |
| } | |
| enqueue(element) { | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | var obj = {one : 1, two : 2}; | |
| var copiedObj = {...obj}; | |
| copiedObj.one = 3; | |
| console.log(copiedObj.one); // 3 | |
| console.log(obj.one); // 1 | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | function copy(sourceObj) { | |
| let targetObj = {}; | |
| let keys = Object.keys(sourceObj); | |
| for (let i = 0, len = keys.length; i < len; i++) { | |
| let key = keys[i]; | |
| targetObj[key] = sourceObj[key]; | |
| } | |
| return targetObj; | |
| } | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | function JSONCopy(source) { | |
| return JSON.parse(JSON.stringify(source)); | |
| } |