Sunshine168 / resume

My resume
3 stars 1 forks source link

I dont know js #10

Open Sunshine168 opened 6 years ago

Sunshine168 commented 6 years ago

http://javascript-puzzlers.herokuapp.com/

Sunshine168 commented 6 years ago
let a1 = new String('a')
let a2 = String('a')
let a3 = 'a'
console.log(a1 === a2)     // false
console.log(a1 === a3)    //  false
console.log(a2 === a3)   //  true 
parseInt(3, 8)
parseInt(3, 2)
parseInt(3, 0)  //   3, parseInt will consider a bogus radix and assume you meant 10, so it returns 3.
Array.isArray( Array.prototype ) //true 
var a = [0];
if ([0]) {
  console.log(a == true); // false
} else {
  console.log("wut");
}

console.log([0]==0) // true
Number.MIN_VALUE > 0 // true
console.log(Number.MIN_VALUE) // 5e-324
console.log(Number.MAX_VALUE) //1.7976931348623157e+308
(function(){
  var x = y = 1;
})();
console.log(y);  // 1
console.log(x);  // error
Sunshine168 commented 6 years ago
var ary = Array(3);
ary[0]=2
ary.map(function(elem) { return '1'; }); // [2,undefined,undefined]

//map is only invoked for elements of the Array which have been initialized.


function sidEffecting(ary) {
  ary[0] = ary[2];
}
function bar(a,b,c) {
  c = 10
  sidEffecting(arguments);
  return a + b + c;
}
console.log(bar(1,1,1))  // 22
function foo() { }
var oldName = foo.name;
foo.name = "bar";
[oldName, foo.name]  // [foo,foo]

//name is a read only property


[,,,].join(", ")
var a = Date(0);  //current Time string
var b = new Date(0); 1970 Time Object
var c = new Date();   now Time Object