Skip to content

Instantly share code, notes, and snippets.

@edtoken
Last active July 9, 2018 10:16
Show Gist options
  • Save edtoken/85cd8d10b395567c5494b5a2ab636351 to your computer and use it in GitHub Desktop.
Save edtoken/85cd8d10b395567c5494b5a2ab636351 to your computer and use it in GitHub Desktop.

Simply javascript test

1

console.log(1 === '1')

2

difference between var, let, const

3

let i = 5
i--;
console.log(i);

4

function F(x){
  this.x = x;
}

var inst = new F(3);
var result = inst.getSumm(2); // => 5

console.log(result) // => 5
console.log(inst.x) // => undefined

5

var arr = []
console.log(Boolean(arr.length));

6

apply, call, slice, splice, shift, split, join, reverse, replace, filter, find, reduce, Prototype?

6.1

replace all A to B

"ABBBABBBAAA"

7

Make it work

var arr = ['a', 'b', 'c'];
for(var a=0;a<arr.length;a++){
  setTimeout(function(){
    console.log('a', a, arr[a]);
  }, 1);
}

8

let obj = {'1': 0, 1: 1, 0: 2};
alert(obj['1']);

9

sayHi();

function sayHi() {
  alert("Hello");
}

10

let obj = {
 "0": 1,
 0: 2
};

alert( obj["0"] + obj[0] );

11

function func(){
  var f = function(){
    return 1;
  }

  function f(){ return 2; }
  
  return f();
}

console.log(func());

12

var obj = {x:1}

function func(obj){  
  return obj.x
}
setTimeout(() => {
  obj.x = 2;
}, 0);

console.log(func(obj));

13*

function a(){
  // 
}
console.log(a(1)(2)) // => 3
console.log(a(1)(2)(3)) // => 6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment