I find the code below , but I can't understand this.
if (!-[1, ] && !window.XMLHttpRequest) {
document.execCommand("BackgroundImageCache", false, true);
}
What does if(!-[1,])
mean ? Thanks
Python also allows you to index from the end of the list using a negative number, where [-1] returns the last element. This is super-useful since it means you don't have to programmatically find out the length of the iterable in order to work with elements at the end of it.
Artturi Jalli. In Python, [::-1] means reversing a string, list, or any iterable with an ordering. For example: hello = "Hello world" nums = [1, 2, 3, 4]
It means "subtract one from the previous value". Same thing it always means. Possibly you intended to ask "why is it there?" In that case, the answer is that JavaScript arrays are zero-indexed, which means the last index in the array is one less than the length of the array (because the first index is 0, not 1).
It's a hack to detect old Internet Explorer. -[1,]
is -1
in modern browsers (so false
with !
) but NaN
in old IE (true
negated). The first version to return correct result is IE9.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With