10道前端基础题

第1题

var y = 1;  
if (function f(){}) {
    y += typeof f;  
}  
console.log(y);

第2题

var output = (function(x){
    delete x;
    return x;  
})(0);    
console.log(output);

第3题

var x = 1;
var output = (function(){
    delete x;
    return x;  
})();    
console.log(output);

第4题

var x = { foo : 1};
var output = (function(){
    delete x.foo;
    return x.foo;  
})();    
console.log(output);

第5题

var Employee = {
  company: 'xyz'
}
var emp1 = Object.create(Employee);
delete emp1.company
console.log(emp1.company);

第6题

var trees = ["xyz","xxxx","test","ryan","apple"];
delete trees[3];    
console.log(trees.length);

第7题

var bar = true;
console.log(bar + 0);   
console.log(bar + "xyz");   
console.log(bar + true);   
console.log(bar + false);  

第8题

var z = 1, 
y = z = typeof y;
console.log(y);  

第9题

var foo = function bar(){
  return 12; 
};
typeof bar();  

第10题

var salary = "1000$"; 
 (function () {
     console.log("Original salary was " + salary);          
     var salary = "5000$";
     console.log("My New Salary " + salary); 
})();

你可能感兴趣的:(10道前端基础题)