In Chrome, this fiddle prints false. However, the same code typed in the JavaScript console prints true:
a = 1;
var a = 2;
console.log(delete a);
Why do I get different results depending on whether or not I’m using the Chrome console?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Because the Chrome console runs inside an
evalconstruct or something similar, rather than running in the global scope.There is a lot of discussion about the
deleteoperator here on StackOverflow. A search for[javascript] deletewill help answer other questions that come up.