I was perusing the underscore.js library and I found something I haven't come across before:  if (obj.length === +obj.length) { ... }   What is that + operator doing there? For context, here is a direct link to that part of the file....
I found the following code in a JS project:  var a = new Array(); a[0] = 0; for (var b = 0; b < 10; b++) {   a[0] |= b;  }   What does the |= do in the body of the for loop?  The code example is dubious, but has been presented here by V8 for an ex...
I understand the difference in behavior. Date() returns a String representing the current date, and new Date() returns an instance of the Date object whose methods I can call.  But I don't know why. JavaScript is prototyped, so Date is a function...
Edit: This question is out of date as the Polyfill example has been updated. I'm leaving the question here just for reference. Read the correct answer for useful information on bitwise shift operators.    Question:  On line 7 in the Polyfill exam...
I'm trying to understand how the comma operator (,) works in JavaScript, it seems to have a different behaviour when it's not put between parenthesis.   Can someone explain me why ?   Exemple for reference :     var a = 1;  var b = 2;  var c...
I was examining the src of underscore.js and discovered this:  _.isRegExp = function(obj) {     return !!(obj && obj.test && obj.exec && (obj.ignoreCase || obj.ignoreCase === false)); };   Why was "!!" used? Should it...
Sorry, I'm a bit of a noob when it comes to javascript. But here is my problem: The following function returns -1 when 0 is inputed  function foo(bar){     return bar || -1; }  foo(0);   is there a nice and elegant way to allow the || operator to...
If I put this line into JavaScript console (you do not need to declare "foo")  foo : 4;   What exactly this line means? Does "foo" live in any context? Is : any operator?...
I just encountered the code below.  var loadComplete = 0; window.onload = function(){     loadComplete |= 1; };   I've never seen "|=" like operator. Also I have googled about it, but there seems to be no example of it....
EDIT: I have to make this work on IE11  I have the following code:  span.classList.add(span.textContent === '\ ' ? 'char' : 'spaceChar')   It is working fine, but I would like to add 2 classes in case it's true, something...

Tags

Recent Questions

Top Questions

Home Tags Terms of Service Privacy Policy DMCA Contact Us

©2020 All rights reserved.